I am trying to stream audio bytes into an naudio waveout stream but it isn't working. Here is the pseudocode:
byte[] by = new byte[2560] //audio packet sizes
int counter=0;
while (true) { //keep receiving bytes from incoming TCP socket
int bytesAvailable = await stream.ReadAsync(by, 0, 2560); //read incoming bytes
if(counter==0) {
using (var MemoryStream = new MemoryStream(by)) {
var waveOut = new WaveOut();
var waveFormat = new WaveFormat(16000, 16, 2); // wave format
var rawSource = new RawSourceWaveStream(MemoryStream, waveFormat);
waveOut.Init(rawSource);
waveOut.Play();
counter++;
}
}
..but I am not hearing anything. I am guessing it just reads one packet and stops, but I don't know.
Anyone know what is wrong/how to fix? I know the bytes are coming in because I print out the last byte so it's nothing to do with the network receive.