在 UWP App 中访问系统音频

Access system audio in UWP App

我想编写一个

  1. 通过用户在另一个应用程序中播放来访问音频
  2. 分析音频
  3. 向用户显示分析结果

但是,我还没有发现任何使这看起来成为可能的东西。应用程序能否以字节流的形式访问通过用户扬声器播放的音频,或者这不是内置在 API 中吗?

使用 MediaCapture class 捕捉音频。 link to docs

Can apps access access the audio being played through the user's speakers as a byte stream or is this not built into the API?

你可以做到(Loopback recording), but you need to program with low level APIs - WASAPI. For available APIs for UWP, check the Core Audio part in Win32 and COM for Windows Runtime apps and Universal Windows Platform (UWP) apps (multimedia)

这是 GitHub 上关于 WASAPI 和 Core Audio API 的旧 article for 8.1 app, but it still applies to UWP on concept level. And Microsoft has provided a sample,这可能有助于您熟悉 API并了解如何使其在 UWP 应用程序中工作。