title: NAudio record and save microphone input and speaker output
body: <p>I want to record conversations over Skype or similar applications (these recordings will be processed after being saved). I was trying to accomplish that with NAudio.</p>
  
  <p>So far I managed to record speaker audio using WasapiLoopbackCapture and save it to a WAV file, also I managed to record and save microphone audio using WaveIn. The main problem is that I cannot mix these 2 files into a single file, as stated in the following link: <a href="https://github.com/naudio/NAudio/blob/master/Docs/MixTwoAudioFilesToWav.md" rel="nofollow noreferrer">https://github.com/naudio/NAudio/blob/master/Docs/MixTwoAudioFilesToWav.md</a></p>
  
  <p>The function where I start my recording looks like this:</p>
  
  <pre><code>        waveSourceSpeakers = new WasapiLoopbackCapture();
          string outputFilePath = @"xxxx\xxx\xxx";
  
          waveFileSpeakers = new WaveFileWriter(outputFilePath, waveSourceSpeakers.WaveFormat);
  
          waveSourceSpeakers.DataAvailable += (s, a) =&gt;
          {
              waveFileSpeakers.Write(a.Buffer, 0, a.BytesRecorded);
          };
  
          waveSourceSpeakers.RecordingStopped += (s, a) =&gt;
          {
              waveFileSpeakers.Dispose();
              waveFileSpeakers = null;
              waveSourceSpeakers.Dispose();
          };
  
          waveSourceSpeakers.StartRecording();
  
          waveSourceMic = new WaveIn();
          waveSourceMic.WaveFormat = new WaveFormat(44100, 1);
  
          waveSourceMic.DataAvailable += new EventHandler&lt;WaveInEventArgs&gt;(waveSource_DataAvailable);
          waveSourceMic.RecordingStopped += new EventHandler&lt;StoppedEventArgs&gt;(waveSource_RecordingStopped);
  
          waveFileMic = new WaveFileWriter(@"xxxx\xxx\xxx", waveSourceMic.WaveFormat);
  
          waveSourceMic.StartRecording();
  </code></pre>
  
  <p>The function where I try to mix my 2 wav files looks like this: </p>
  
  <pre><code>      using (var reader1 = new AudioFileReader(@"xxx\xxx\file1.wav"))
        using (var reader2 = new AudioFileReader(@"xxx\xxx\file2.wav"))
        {
                  var mixer = new MixingSampleProvider(new[] { reader1, reader2 });
                  WaveFileWriter.CreateWaveFile16(@"xxxx\xxx\mixed.wav", mixer);
        }
  </code></pre>
  
  <p>and I get this exception: System.ArgumentException: 'All mixer inputs must have the same WaveFormat' while trying to create MixingSampleProvider.</p>
  
  <p>I was wondering if I am using the right ways to record both audios? Also, it would be great if there is a way to record both audios in one file, but I'm not sure if that is possible.</p>