views:

46

answers:

1

Hi

I'm working currently on a small microhpone, connected to PC via an FPGA. The FPGA spits a raw datastream via UART/USB into my computer. I'm able to record, play and analyze the data.

But I can't play the "live" audiostream directly.

What works is saving the datastream in PCM raw-format with a custom made C-program, and piping the content of the file into aplay. But that adds a 10sec lag into the datastream... Not so nice for demoing or testing.

tail -f snd.raw | aplay -t raw -f S16_LE -r 9000

Does someone have another idea, how get the audiostream faster into my ears? Why does

cat /dev/ttyUSB0 | aplay

not work? (nothing happens)

Thanks so far
marvin

A: 

You need an api that lets you stream audiobuffers directly to the soundcard. I haven't done it on Linux, but I've used FMOD for this purpose. You might find another API in this question. SDL seems popular.

The general idea is that you set up a streaming buffer, then your c program stuffs the incoming bytes into an array. The size is chosen to balance lag with jitter in the incoming stream. When the array is full, you pass it to the API, and start filling another one while the first plays.

AShelly