c++ - WASAPI:识别环回记录中的非事件 channel

标签 c++ audio real-time wasapi

我有一个 DSP 软件,可以在共享环回模式下使用 WASAPI api 捕获播放的音频。

hr = _pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_LOOPBACK, 0, 0, _pFormat, 0);

这部分工作正常,但现在我希望能够检测实际播放的 channel 数。换句话说,我如何能够检测音频播放是立体声、5.1、7.1?

问题是:
* 由于环回必须使用共享模式,因此可以播放多个源。
* 此分析必须实时进行。等不及播放完毕了。
* 检测任何播放源根本不使用的 channel 和暂时静音的 channel 之间的区别

在我看来,最好的解决方案是,如果我可以检索所有播放源/子混音的列表,并分别查询它们的 channel 数量。这样我就不必分析音频数据流本身。

最佳答案

环回录音以端点上定义的混合格式进行,因此无论原始音频格式是什么,您都可以获得混合格式的数据,从可能的多个播放源混合并转换为此类共享格式。

WASAPI loopback contains the mix of all audio being played...

The GetMixFormat method retrieves the stream format that the audio engine uses for its internal processing of shared-mode streams...

After an application has used GetMixFormat or IsFormatSupported to find an appropriate format for a shared-mode or exclusive-mode stream, the application can call the Initialize method to initialize a stream with that format. An application that attempts to initialize a shared-mode stream with a format that is not identical to the mix format obtained from the GetMixFormat method, but that has the same number of channels and the same sample rate as the mix format, is likely to succeed. Before calling Initialize, the application can call IsFormatSupported to verify that Initialize will accept the format.

也就是说,尽管 WASAPI 在音频格式方面提供了一定的灵 active ,但在环回捕获时 channel 配置和采样率由共享格式定义。

在进行混音时,您无法真正识别“非事件” channel :此信息在混音为共享格式的过程中会丢失。

此外,实际的共享格式可以通过控制面板交互配置:

enter image description here

关于c++ - WASAPI:识别环回记录中的非事件 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48335752/

相关文章:

c++ - 如何使用 boost 升级互斥体扩展 C++ boost 列表容器以实现线程安全实现?

c++ - dynamic_cast 工作时程序应该失败/崩溃

c++ - 如何找到数组组的最大值

javascript - 使用网络音频 api 分析来自麦克风的输入(将 MediaStreamSource 转换为 BufferSource)

c++ - 获取图片的压缩比

iphone - 在 iOS 上演奏音符或简单的声音?

iphone - 音量卡在低电平,调节音量没有效果?

mysql - 实时查询数据库发送命令

python - 具有实时输入和多个控制台的Python子进程

android - C2DM 源代码在哪里?