PDA

View Full Version : Playback options for network Data.



technomage
03-03-2005, 09:27 PM
Hi Everyone

i'm hoping for some ideas here. :)

I've created an application that records audio data and sends this to another machine for playback. The problem is what method to use to play back the data on the other end. So far i have managed to take this data and save it to a audio file to prove it works, but i need to play the data in real time ( as it arrives).

I'm new to FMOD so I was wondering if anyone has any suggestions :?:

The added complication is that I could have many clients sending data and this would all need to be played (mixed?)

Any thoughts or suggestions would be helpful. :D

Sly
03-03-2005, 09:40 PM
Check out the stream2 sample that comes with FMOD. It demonstrates a stream with a user callback to populate the stream data. Based on this example, you could receive the data over the network, buffer it, and fill the stream buffer in the callback when required.

technomage
03-03-2005, 10:01 PM
Thanks Sly, I'll check out that example.

Any ideas on how to handle data fro different machines? Should each piece of data be placed in it's own stream or should I merge the data, or just play it as it comes in ??

Sly
03-03-2005, 10:03 PM
Create multiple streams and FMOD will handle the mixing.

technomage
04-03-2005, 10:47 PM
ok, I'll look at that.

one question about streams. the data I'm getting from the remote system is not going to be arriving at a constant rate. My under standing of a Stream it that the callback will be called when the stream needs more data. If I return False in the call back if no data is available will that stop the playback? If so that it should be an easy task to stop and start the plaback as the data arrives.

Any suggestions on the buffering of the data? Actually, I just had a thought if I store the incomming daa packes in a queue the stream can just grab the top packed and process that, and stop the stream if no packets are in the queue... that way the memory useage of the buffer should be kept to a minimum.... :)

Sly
05-03-2005, 02:35 AM
That should work fine. Buffer the data yourself and then give it to the stream as the stream requests it. If you run out of data, you could just supply a whole load of blank data to the stream so you get no sound, but the stream is still playing.

technomage
06-03-2005, 09:51 PM
Well the good news is that the queue idea worked ( have a weird AV that occurs during playback, which I can't trace, but I'll nail it :D )

What I did was paused the stream to start with until data arrives when i unpause it. When the queue is empty I just pause the stream, until more data arrives.

Thanks for your feedback, it really helped :D

Sly
06-03-2005, 10:34 PM
Excellent stuff. :)