Is it possible to obtain the peak meter readings for individual programs on Windows 7, and if so, how?
With WASAPI one can capture the entire system audio through a loopback device, but this does not differentiate between outputs from different programs. This question regards capturing audio for a single specified application, but the answers seem prohibitive when dealing with capturing all programs that are playing audio individually. This must be possible because SndVol can do it, as shown in the image below. The question is how is it being accomplished? Is it being done through unexposed API calls or is it actually possible to achieve something like this through WASAPI as well?
Thanks.
You are enumerating audio sessions and getting IAudioSessionControl
interfaces (MSDN code snippet). The missing part is that you can query IAudioMeterInformation
inteface from IAudioSessionControl
you are already holding.
If the audio endpoint supports peak meters, you will be able to obtain this interface, and use IMeterInformation::GetPeakValue
for individual sessions. And this is what SndVol supposedly doing.
Here is a piece of code that does the thing:
CComPtr<IAudioSessionControl> pSessionControl;
...
CComQIPtr<IAudioMeterInformation> pMeterInformation = pSessionControl;
FLOAT fPeakValue;
pMeterInformation->GetPeakValue(&fPeakValue);
_tprintf(_T("nSessionIndex %d, fPeakValue %.2f\n"), nSessionIndex, fPeakValue);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With