This project has moved and is read-only. For the latest updates, please go here.

Buffering / Mixing - Distortion / Choppy Audio

Sep 26, 2013 at 8:35 PM
I've run into some issues while mixing audio sources (VOIP).

I think it has to do with buffering, because when I created a local test, everything mixed fine. Any network and codec compression delays, and you get choppy audio when more than two providers are being mixed.

My current setup:
  • Each input has their own BufferedWaveProvider
  • I have a single MixingSampleProvider (With ReadFully = True)
  • Wave Format: 48khz (32khz too) / 16-bit PCM / 2 channels (Tried 1 channel as well)
  • Tried no codec, Speex, and Opus
  • WaveIn - BufferMilliseconds: 50
  • WaveIn - NumberOfBuffers = 1 (Tried 2)
Everything sounds great when there is only one active audio source.

So what is the best way to mix stream audio sources together?

Sep 29, 2013 at 8:15 AM
Choppy audio is likely that the BufferedWaveProviders are not providing data fast enough. This type of real-time mixing is very tricky as you want the lowest latency possible. One way to debug is to write each of the mixer inputs to a WAV file as it is going into the mixing sample provider. Then you can individually listen to what each of the inputs was to see where the problem is.

As for WaveIn, it is not particularly good at low latencies, and I'm amazed it works at all with buffers = 1. You should be using 2. Otherwise its being refilled while you read out of it.
Sep 29, 2013 at 3:29 PM
Alright, I'll give that a shot.

For WaveIn, is there any other option for recording microphone input? I'm not an audio expert, but I see WASAPI, Wave, DirecntSound, etc for output, but not input.
Sep 29, 2013 at 6:43 PM
WaveIn is actually the easiest to use because it supports resampling, but there is WasapiCapture, and the AsioOut class can be used for recording as well.