如何收听Windows当前正在播放的声音?

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

我想构建一个应用程序,"listens" 播放 Windows(7 到 10)可能正在播放的任何声音(网络浏览器中的 Winamp、Youtube 等)。 我不想拦截、修改或重定向声音。只能去听,去分析。

我更愿意只听音乐源...但这是另一个问题:)

什么 API 可以做到这一点?

如果您只是想从 WASAPI 获取输出组合,您可以按照 MSDN 上的本指南进行操作,因为 Loopback Recording. If you're interested in hooking the output from specific applications only, 有许多已经涉及该主题的答案。

对于环回录制,请注意有关 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.