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

Mixdown multiple WAVs to a single file - solved

Jul 9, 2012 at 4:26 PM


similar to this( problem, I'm looking for a clever solution to mixdown n files (mono) to a single file (stereo or mono doesn't matter). 

I run into WaveMixerStream32 but I don't know how to handle it correctly.

Also I'm looking for a way to amplify/normalize the mixdown. Do some of you have any ideas how to do that in NAudio?


Jul 12, 2012 at 5:57 PM

 private WaveFileWriter writer;
 private List<WaveFileReader> inputs = new List<WaveFileReader>();

    private void button1_Click(object sender, RoutedEventArgs e)
            foreach (string s in blah.audiofilenames)
                inputs.Add(new WaveFileReader(s));

            var waveProvider = new MultiplexingWaveProvider(inputs, inputs.Count);
            writer = new WaveFileWriter(@"D:\temp\mixdown.wav", waveProvider.WaveFormat);

            int bytesRead = 0;
            int buffer_size = 4096;

            while (true)
                byte[] bytes = new byte[buffer_size];
                    bytesRead = waveProvider.Read(bytes, 0, buffer_size);
                catch (Exception ec)
                    //  throw ec;

                if (bytesRead == 0)

                    if (writer != null)

                writer.Write(bytes, 0, buffer_size);


This is the code that solved my first problem. It is generating a multitrack wave file (8+ tracks in one file in my case). Of course you could put this in its own thread.

Apr 18, 2013 at 8:37 PM
Edited Apr 18, 2013 at 8:50 PM
Hi i used this code works fine but after mixdown two wav files i cant delete them i have IO error file is in use. I mean source files.
Apr 18, 2013 at 9:05 PM
Solved :)
            foreach (WaveFileReader wave in inputs)