sipsorcery
sipsorcery

Reputation: 30714

WaveInEvent sample event frequency

I'm using the code block below to receive samples from my microphone and pass them to an RTP channel on a SIP call. The problem is the samples are arriving every 200ms whereas I'm expecting them every 20ms. The samples are the right size for a 20ms sampling interval at 20ms it's just that the 20ms samples only arrive every 200ms. I'm probably doing something silly with my WaveInEvent set up?

var _waveInEvent = new WaveInEvent();
_waveInEvent.BufferMilliseconds = 20;
_waveInEvent.NumberOfBuffers = 1;
_waveInEvent.DeviceNumber = 0;
_waveInEvent.DataAvailable += RTPChannelSampleAvailable;
_waveInEvent.WaveFormat = new WaveFormat(8000, 16, 1);

Upvotes: 1

Views: 2949

Answers (1)

Mark Heath
Mark Heath

Reputation: 49522

You normally have at least two buffers, so you can be examining one while another is filled. 20ms might be a little bit quick for WaveIn to cope with. Check how many bytes are in the DataAvailable callback buffer. With your values, you should be getting 320 bytes at a time.

Upvotes: 1

Related Questions