Question

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.

Was it helpful?

Solution

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);

OTHER TIPS

Looking at WASAPI there is an interface to capture audio from a given client, but I don't see any higher level interface for determining peak levels. You may need to write some code to do that, unless there is a library out there that someone has created to do some higher level audio work with this WASPI. CHEERS!

Here is another shot at it: IChannelAudioVolume::GetChannelVolume. I followed the thread on MSDN from SndVol, and this is where I ended up. Quoting from the web page: "The GetChannelVolume method retrieves the volume level for the specified channel in the audio session." You would have to write some software to extract the peak value from this stream. My quick guess would be just to compare if the current value is larger than the last largest value. If so, then the current value becomes the peak.

CHEERS!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top