Hi All;
Im looking to read a stream of 16 bit signed ints into a buffer, then pass that buffer off to a function. Another program provides raw data as 16 bit signed integers, and I pipe them through to stdin via command line.
This is what I have so far, and while it does not error, I am not getting data back that i would expect from the function. Im thinking its not correctly passing the buffer to the function, or its type is not right. Fairly new to C.
Code:
#include "fsync_decode.h"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
main()
{
fsync_decoder_t *decoder;
int result;
int samplerate = 22050;
short buffer[1024];
decoder = fsync_decoder_new(samplerate);
while(1)
{
read(0, buffer, 1024);
// Pass samples to function, will return 0 if it needs more samples
// Returns -1 if there is an error.
int result = fsync_decoder_process_samples(decoder, buffer, sizeof(buffer));
switch(result)
{
case 0: break;
case -1: exit(1);
}
}
}
The function belongs to a library which has been used elsewhere and works.. link: GitHub - atmatthewat/fsync-encode-decode: Software modem for a specific data burst format