Search code examples
c#audiorecordnaudio

Need to record all sounds from sound card with NAudio in Windows 7


Need to record all sounds from sound card. So that mic+output was written to file.
Is it possible to do with NAudio library in Windows 7? Cant find any examples, found just ones that allow to write mic or just sound from speakers, not both.
PS, sorry, if the question looks not ok..Im new to audiorecording.
Added issue ive asked on codeplex: http://naudio.codeplex.com/workitem/16353


Solution

  • To record sounds being played by the soundcard, you would use WASAPI in Loopback Mode. To record sounds going into the microphone you could use WASAPI capture, or any of the other microphone capture classes in NAudio.

    Then you have the slightly tricky job of mixing those two inputs together. This may require sample rate conversion beforehand, and it may require you to timestamp the recorded audio (as the loopback audio can contain gaps when nothing is being played).

    With NAudio, you would convert both streams to floating point, before mixing them using one of the "Mixer" wave or sample providers in NAudio, and then writing that back out to a file.

    So yes it is possible, and I have done it once before myself, but it does require you to write a fair bit of your own code on top of the core NAudio libraries.