Using SpeexJitterBuffer

Aug 31, 2011 at 9:53 AM

Hi Christoph,

Some issues which need your help. I have got some data stream encoded by NSpeex(with size of tens of KB). Now I need to decode it with JitterBuffer and not very clear to how to set the decodedBuffer size. The code is following:

SpeexDecoder decoder = new SpeexDecoder(BandMode.Wide);
SpeexJitterBuffer jitterBuffer = new SpeexJitterBuffer(decoder);




//HOW to set the buffer size here?
short[] decodedBuffer = new short[decoder.FrameSize * 2];
for (int i = 0; i < decodedBuffer.Length; ++i)
	if (bytesRead < count)
		short currentSample = decodedBuffer[i];
		BitConverter.GetBytes(currentSample).CopyTo(buffer, offset + bytesRead);
		bytesRead += 2;
		// todo: handle the overhead; we decoded more bytes as the audio playback has requested


I have tried to decode it piece by piece (the piece size is encodedFrameSize), but there are still errors during "jitterBuffer.Get(decodedBuffer)" such as OutOfRange...


Sep 30, 2011 at 6:33 AM
Edited Sep 30, 2011 at 6:34 AM

Hi, it's been a while since your post,

there is a working example which shows how to use the provided JitterBuffer under:

There, I basically wrapped the JitterBuffer into a WaveProvider which is required for NAudio playback but it should the principle.