IWaveProvider - streaming 16Bit PCM audio

Feb 20, 2013 at 10:09 PM
I have previously created a IWaveProvider to convert streaming Mulaw to PCM and play the audio back. I am now using the same provider to use a specific WaveFormat based on an RTSP describe value of L16/16000/2, which should be PCM 16 bit, 16000hz 2 channels. So my WaveFormat is defined as follows:
waveFormat = new WaveFormat(16000,16,2);
When I use the AddSamples method, I am simply writing out the byte array directly to my circular buffer:
written = circularBuffer.Write(buffer, offset, count);
However, on playback, it is definitely not the correct format. Just wondering if I should be converting the incoming data before adding it to the circular buffer?
Coordinator
Feb 21, 2013 at 11:39 AM
one way to diagnose problems like this, is to use the WaveFileWriter to create a WAV file. If it doesn't play back correctly, try different WAV formats until you hear it correctly. That will help you find out what waveformat you really have
Feb 21, 2013 at 7:54 PM
The PCM data was streamed from the network and was big endian, after swapping the bytes to make it little endian, the audio played fine. Saw that in another thread.
Coordinator
Feb 25, 2013 at 8:40 PM
great, glad you worked it out
Mar 28, 2013 at 2:53 PM
Is there a way to convert Big Endian formatted received bytes from network to little endian for recording as wave file?

I have to convert 512 bytes for each 16 ms interval from big endian to little endian for my recorder, and I wonder if cpu can handle this operation.

My incoming stream from network is 8Khz, 16 bit, stereo.

I am searching if NAudio has an utility for handling this kind of problem.

Thanks.
Coordinator
Mar 28, 2013 at 5:12 PM
nothing built in to NAudio. I'd just swap each pair of bytes in the incoming buffer before moving on.