Grab Audio Sessions as they appear in the windows

2019-06-12 04:39发布

问题:

I'm trying to figure out how to grab the individual audio streams as they appear in the audio mixer to reroute them to an aggregate audio device. I'm specifically looking to keep them as discreet streams for the purposes of the program I'm making (If they're muxed down to a 2-channel mix, that defeats the purposes of what I'm trying to achieve.)

E.X.: (As I've just made this account, I apparently am not able to post images, so here's a link to the image)

windows audio mixer

In this, I'm hoping to grab "System Sounds" and "Stream Client Bootstrapper" as discreet audio streams to route elsewhere, while maintaining their original destination as well (essentially copying the audio going to the original audio device to another simultaneously).

I'm looking to do this in either C# or C++. I've perused the audio APIs that microsoft has published, and while some things look to be close to what I'm trying to do, nothing has hit the nail on the head. I appreciate any help. Thanks.

回答1:

The sessions can be enumerated using IAudioSessionManager2::GetSessionEnumerator and friends (sample C++ code is here and there). Standard Windows volume mixer application is using this API as well.

The API however has no access to data streams, you won't have either (you certainly don't have data whether they are downmixed or not). Neither you can reroute streams to another device. Applications are not allowed to interfere that deep. The best you can do is to create your own device, interactively select it as default output device and then accept data from applications playing audio through this device.