I'm trying to convert a stereo .wav file to mono using NAudio. One requirement is that I cannot use any native calls, as I need to run this code on Azure. Here's what I came with:
using (var waveFileReader = new WaveFileReader(sourceFileName))
{
var toMono = new StereoToMonoProvider16(waveFileReader);
WaveFileWriter.CreateWaveFile(destFileName, toMono);
}
My code works without errors, but the output is a file that contains pure silence.
Is there any other way to convert a file to mono?
You need to provide values for the LeftVolume
and RightVolume
properties of the StereoToMonoProvider16
. For example, set them both to 0.5f to mix the channels, or set left to 1.0 and right to 0.0 to discard the right channel