I assume you're trying to mix multiple files of a different sample rate. Here's how you can do it with NAudio (I'm using the MediaFoundationResampler, but there are other ways of resampling)
var paths = new[] {
@"input1.wav",
@"input2.wav",
@"input3.wav"
};
// open all the input files
var readers = paths.Select(f => new WaveFileReader(f)).ToArray();
// choose the sample rate we will mix at
var maxSampleRate = readers.Max(r => r.WaveFormat.SampleRate);
// create the mixer inputs, resampling if necessary
var mixerInputs = readers.Select(r => r.WaveFormat.SampleRate == maxSampleRate ?
r.ToSampleProvider() :
new MediaFoundationResampler(r, WaveFormat.CreateIeeeFloatWaveFormat(maxSampleRate, r.WaveFormat.Channels)).ToSampleProvider());
// create the mixer
var mixer = new MixingSampleProvider(mixerInputs);
// write the mixed audio to a 16 bit WAV file
WaveFileWriter.CreateWaveFile16(@"d:\mixed.wav", mixer);
// clean up the readers
foreach(var reader in readers)
{
reader.Dispose();
}
Note that this won't deal with a mixture of mono and stereo input files. In that case, you'd need to also convert mono inputs to stereo (e.g. using MonoToStereoSampleProvider
).