This project has moved. For the latest updates, please go here.

Playing from a stream

Sep 20, 2009 at 8:35 PM
Edited Sep 20, 2009 at 8:43 PM

Using the WaveInStream, I'm capturing data from the microphone, if I were to package up this data and send it across a network, what's the best way to play it at the other end? I can't find any class which accepts a MemoryStream and plays it (or a stream, or byte array).

Sep 23, 2009 at 8:20 PM

Please see:

Sep 24, 2009 at 12:25 PM

That technique needs to know the complete length of the stream though, I want to receive the data and start playing it even as I'm receiving more.

Should I maybe have a buffer of 1 second (however many bytes that is) and play that buffer when it's full, which would work so long as latency was less than one second, I believe.

Sep 24, 2009 at 2:09 PM

There is no need to know the length in advance. I would create a derived class from WaveStream that in its Read method returned buffered audio received over the network. If you have run out of data you can either return a zeroed out buffer, or return 0 bytes if you want playback to stop.

The example on stackoverflow shows it stopping when Position >= Length, but there is no reason for that to be the case.


Sep 24, 2009 at 2:21 PM

Ahh ok, apologies for my terminal stupidity about all this, I've never done any kind of audio programming before :/


Thanks very much!