2

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?

Gabriel
  • 20,797
  • 27
  • 159
  • 293
  • 1
    Don't want to dupehammer just yet, but [maybe this?](https://stackoverflow.com/q/31623824/327083) – J... Feb 14 '20 at 16:43
  • 2
    There are [four good linked answers](https://stackoverflow.com/a/31623980/327083) that are more focused. Did you read them all in 90 seconds? – J... Feb 14 '20 at 16:46
  • I need a solution to the problem so of course, I will scour all of them in the hope of an answer. I am on it. – Gabriel Feb 14 '20 at 16:48
  • 1
    [This one](https://stackoverflow.com/q/13107368/327083) starts from the point you want to get to - grabbing the output mix from WASAPI, but looking to get an individual application's stream instead. Naturally, we can conclude that WASAPI can probably get you the mixed output you want. – J... Feb 14 '20 at 16:50
  • 1
    See also : [MSDN : Loopback Recording](https://learn.microsoft.com/en-us/windows/win32/coreaudio/loopback-recording) – J... Feb 14 '20 at 16:53
  • @J... - Man, those are exactly the pointers I needed. When I started the question I didn't even knew exactly how to formulate it. The last link seems to give me what I want. Thanks. I upvoted all your comments. – Gabriel Feb 14 '20 at 16:57

1 Answers1

3

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.

J...
  • 30,968
  • 6
  • 66
  • 143
  • [DRM] hm... this could mean YouTube? – Gabriel Feb 14 '20 at 17:00
  • 1
    @HappyBirthdayDelphi_25 Yes, I believe youtube does support (and uses) DRM in their content - I'm not sure whether this would preclude loopback recording as above, but I wouldn't be surprised. – J... Feb 14 '20 at 17:03
  • It probably doesn't include YouTube *most of the time* but I bet it does include Netflix. – user253751 Feb 14 '20 at 17:52
  • @user253751 I admit I don't really know. YouTube has toyed on and off with DRM for years - mostly for flagging and catching pirated re-uploads, but I'm not sure if they perhaps DRM all of their videos to prevent loopback scraping, etc. Should be easy enough to test. – J... Feb 14 '20 at 18:03