Search code examples
c++windowsdelphiaudioaudio-streaming

How to listen to the sound that Windows is currently playing?


I want to build an app that "listens" to any sound (Winamp, Youtube in web browser, etc) that Windows (7 to 10) might be currently playing. I don't want to intercept, modify or redirect the sound. Only to listen to it and analyze it.

I would prefer to listen only to the music sources... but that's another question :)

What is the API that could do that?


Solution

  • If you simply want to grab the output mix from WASAPI you can follow this guide on MSDN for Loopback Recording. If you're interested in hooking the output from specific applications only, this question has a number of answers that already touch on this topic.

    For loopback recording, do note the caveats about DRM :

    Windows Vista provides digital rights management (DRM). Content providers rely on DRM to protect their proprietary music or other content from unauthorized copying and other illegal uses. WASAPI does not permit loopback recording of digital streams that contain DRM-protected content. Similarly, a trusted audio driver does not permit a loopback device to capture digital streams that contain protected content. Windows Vista allows only trusted drivers to play protected content.