Sound: loopback recording

I tried code from a number of blogs in an effort to get WASAPI loopback recording working. I only succeeded with one, but that obviously is good enough. The challenge is that WASAPI has a C++ interface. The fundamentals of C++ are simple enough… but when it comes to calling unmanaged code from .Net, I struggle, and need help.

The “winner” then is this person’s Github repository , and specifically his entry on loopback-capture here.


Helpfully the .sln built fine in VS2015.

Executing it after building then consisted of going to the Debug folder. First I naively tried loopback-capture without arguments, which gave me this:


The “something bad happened” turns out to be a symptom of no active audio playback being detected.
Stepping back, you have a help option:


Listing devices gives me this:


Running the single found device, with no file name, and making sure you are currently playing audio, results in a default-named  wav file being saved to the current location. The “… spurious glitch… ” below seems to happen regardless. A packet in this context is doubtless a loss I could not even hear, although I have yet to prove that.