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)?
-
I think this would be sound card specific. I'm not 100% certain though. Interesting question, does this question help? http://stackoverflow.com/questions/1292076/capture-sound-output-in-c – Chris Pfohl Feb 10 '11 at 03:49
-
@drachenstern: your edit was *not* what the person was asking. – MusiGenesis Feb 10 '11 at 04:23
-
@MusiGenesis I wasn't sure one way or the other. It seemed to be the other way. – jcolebrand Feb 10 '11 at 04:25
-
@musi No. We do smartgrid stuff, so to speak. – jcolebrand Feb 10 '11 at 13:31
-
@Musi ~ I like it for now, check back with me in five years ;) – jcolebrand Feb 10 '11 at 15:01
-
Interesting... @Musi do you ever use the chat feature here on the site? – jcolebrand Feb 10 '11 at 16:28
-
@drach: no, I've said too much already. :) If I suddenly disappear, will you tell my parents I loved them? – MusiGenesis Feb 11 '11 at 03:04
-
@Musi ~ lol, indeed sir. – jcolebrand Feb 11 '11 at 03:21
4 Answers
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.

- 74,184
- 40
- 190
- 334
-
1Is this the one? http://www.pinvoke.net/default.aspx/winmm/waveinopen.html?diff=y – Chris Pfohl Feb 10 '11 at 04:03
-
1http://winmm.codeplex.com/ is an excellent C# wrapper of the `winmm.dll` API functionality. – MusiGenesis Feb 10 '11 at 04:10
-
I should clarify my answer here by saying that the `waveInOpenEtc.` API is a royal $@&$!#& to use in C#, unless you find a good code sample that wraps it up for you, like the above. – MusiGenesis Feb 11 '11 at 03:13
-
3There is a **working** example here. http://stackoverflow.com/questions/18812224/c-sharp-recording-audio-from-soundcard – Florian Apr 05 '14 at 09:33
-
@MusiGenesis, Is there any way to capture the byte stream before it is converted to analogue? – Kamran Dec 05 '22 at 01:26
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

- 11,672
- 5
- 42
- 59
-
2In NAudio, there is a `WasapiCapture` class, that can be used for capturing using WASAPI loopback. – svick Aug 23 '11 at 11:57
-
1There has recently been added a `WasapiLoopbackCapture` class that simplifies this process. As of Aug 2012 it is not included in the v1.5 release, I had to download the sources and compile to use it. – Paccc Aug 29 '12 at 02:25
-
1see http://stackoverflow.com/questions/18812224/c-sharp-recording-audio-from-soundcard for a **working** solution – Florian Jun 26 '14 at 08:17
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

- 41
- 3
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

- 106
- 1
- 4