是否可以获取 Windows 7 上各个程序的峰值仪表读数,如果可以,如何获取?
使用 WASAPI,可以通过环回设备捕获整个系统音频,但这不会区分不同程序的输出。 This question关于为单个指定应用程序捕获音频,但在处理捕获所有单独播放音频的程序时,答案似乎令人望而却步。这一定是可能的,因为 SndVol 可以做到,如下图所示。问题是它是如何实现的?它是通过未公开的 API 调用完成的,还是实际上也可以通过 WASAPI 实现类似的目的?
谢谢。
最佳答案
您正在枚举 Audio Session 并获取 IAudioSessionControl
接口(interface) (MSDN code snippet )。缺少的部分是您可以从您已经持有的 IAudioSessionControl
查询 IAudioMeterInformation
界面。
如果音频端点支持峰值计,您将能够获取此接口(interface),并为各个 session 使用IMeterInformation::GetPeakValue
。这就是 SndVol 应该做的。
这是一个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);
关于windows - Windows 7 上各个程序的峰值表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14313692/