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));
           waveout.Init(mixer);
           waveout.Play();
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));
        try
        {

            for (int y = 0; y < counter; y++)
            {
                audioFileReader = new AudioFileReader(inputFiles[y]);
                mixer.AddMixerInput((ISampleProvider)audioFileReader);
            }
        }
            catch( Exception e)
            {
                MessageBox.Show(e.Message);
                return;

            }

        if (flag == true)
        {
            mixer.AddMixerInput((ISampleProvider)sineWaveProvider);
        }
        SampleToWaveProvider mixer2 = new SampleToWaveProvider(mixer);
          waveout.Init(mixer2);
           waveout.Play();
        }
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?
Coordinator
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