Reputation:
Is it possible to record Window's output sounds programmatically in C#? A bit like recording something from the "what you hear" or "stereo output" feature (without having to select them)?
Upvotes: 10
Views: 29151
Reputation: 116
If you want to capture audio output you can use "WasapiLoopbackCapture" https://github.com/naudio/NAudio/blob/master/Docs/WasapiLoopbackCapture.md
If you want to capture audio input you can use "RecordWavFileWaveIn" https://github.com/naudio/NAudio/blob/master/Docs/RecordWavFileWinFormsWaveIn.md
Just install the reference package - https://www.nuget.org/packages/NAudio
Upvotes: 1
Reputation: 41
I'm a bit tardy to the party, but CSCore has a pretty great library for managing windows audio events in C#.
This in particular looks like what you're wanting. http://filoe.github.io/cscore/sharpDox/1.2.0-release/#type/WasapiLoopbackCapture
Upvotes: 4
Reputation: 11858
Also checkout the NAudio library.
PS. C++ but relevant http://blogs.msdn.com/b/matthew_van_eerde/archive/2008/12/16/sample-wasapi-loopback-capture-record-what-you-hear.aspx?PageIndex=2
Upvotes: 6
Reputation: 75296
This is called loopback recording, and it is possible in Windows. If you have a soundcard that supports loopback (I just checked on my low-end Toshiba laptop, and it doesn't) you can record straight from the loopback device using the waveInOpen
etc. API, which is easy to use in C#. Note: recording audio in this way necessarily entails a reduction in quality, since the audio signal is converted to analog for output and then re-digitized to support the loopback interface.
If you don't have a soundcard, WASAPI will let you do this. I suppose WASAPI can be used with C#, but it looks painful.
Upvotes: 8