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

combine two MP3 files and a sineWaveProvider

May 7, 2014 at 6:37 PM
Edited May 7, 2014 at 6:57 PM
I want them to be in one file and play at the same time. so not just in one file and play one after the other, but play at the same time.
how do i do that ?

I believe I need to use a mixer

I am trying this code but I am getting an error :
        MixingSampleProvider mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(44100,1));
the error is
Error 3 Argument 1: cannot convert from 'NAudio.Wave.SampleProviders.MixingSampleProvider' to 'NAudio.Wave.IWaveProvider'
Error 2 The best overloaded method match for 'NAudio.Wave.WaveOut.Init(NAudio.Wave.IWaveProvider)' has some invalid arguments

Why ?
May 7, 2014 at 8:40 PM
ok this is the my mix function:

        void Mixingfunction(List<string> inputFiles)
        MixingSampleProvider mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(44100,1));

            for (int y = 0; y < counter; y++)
                audioFileReader = new AudioFileReader(inputFiles[y]);
            catch( Exception e)


        if (flag == true)
        SampleToWaveProvider mixer2 = new SampleToWaveProvider(mixer);
I am getting an runtime error at mixer.AddMixerInput((ISampleProvider)audioFileReader);
this is when Y is still = to 0.
it says
"All mixer inputs must have the same WaveFormat"
what I am doing wrong?
May 8, 2014 at 9:01 AM
they must all have the same sample rate, bit depth, and number of channels to be mixed. It's probably just the channel count in your instance. Decide if you want to mix in mono or stereo, and then convert all your inputs to the same channel count
Marked as answer by btb4198 on 5/8/2014 at 4:58 AM