Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peak meters for individual programs on Windows 7

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?

enter image description here

Thanks.

like image 478
jonathanasdf Avatar asked Jan 14 '13 05:01

jonathanasdf


1 Answers

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);
like image 118
Roman R. Avatar answered Sep 24 '22 20:09

Roman R.