This project has moved. For the latest updates, please go here.

Recording does not start while there is no audio signal

Dec 29, 2016 at 4:47 PM
I'm trying to record audio from the microfone and the speaker output simultaneously:
micInputAudioSource = new WasapiCapture(micDevice);
micInputAudioWriter = CreateMp3Writer(micInputFileName, micInputAudioSource.WaveFormat, mp3AudioQualityPreset);
micInputAudioSource.DataAvailable += OnMicInputAudioDataAvailable;

outputAudioSource = new WasapiLoopbackCapture(outDevice);
outputAudioWriter = CreateMp3Writer(outputFileName, outputAudioSource.WaveFormat, mp3AudioQualityPreset);
outputAudioSource.DataAvailable += OnOutputAudioDataAvailable;

This works perfectly except that the outputAudioSource only starts recording when there is an actual audio signal. If there is silence, the output file does not contain any data. In this case, the DataAvailable event will be triggered repeatedly but the WaveInEventArgs.BytesRecorded property contains 0, so no samples are written. This is a problem because I need to synchronize both audio signals.

How can I start the recording immediately, even if there is only silence to record?
Or, if this is not possible, how can I synchronize both audio streams to mix them at the exact time?
Jan 26 at 6:55 PM
Seems to be a driver limitation.

You could try to manually create a silent sample buffer and write it to the output file when the
WaveInEventArgs.BytesRecorded property contains 0
Alternatively, grab the NAudio WasapiLoopbackCapture source and experiment with it.