为什么我无法使用 IAudioEndpointVolume::SetMasterVolumeLevelScalar 设置 USB/Firewire 音频接口的主音量
我正在尝试修复围绕 portmixer 的 Audacity 错误。输出/输入电平可以使用 Mac 版本的 portmixer 设置,但在 Windows 中并不总是如此。我正在调试 portmixer 的窗口代码以尝试使其在那里工作。
使用 IAudioEndpointVolume::SetMasterVolumeLevelScalar 设置主音量对于板载声音效果很好,但使用专业外部 USB 或火线接口(如 RME Fireface 400),输出音量不会改变,尽管它反映在该设备的 Window 声音控制面板中,以及系统混合器中。
此外,在我们的程序之外,更改系统混音器的主滑块(在任务栏中)没有任何效果 - 声卡输出相同(完整)的级别,无论系统所说的级别如何。更改输出级别的唯一方法是使用硬件开发人员随卡提供的自定义应用程序。
IAudioEndpointVolume::QueryHardwareSupport 函数返回 ENDPOINT_HARDWARE_SUPPORT_VOLUME,因此它应该能够执行此操作。
许多设备上的输入和输出都存在这种行为。
这可能是 Windows 的错误吗?
可以通过模拟(缩放)输出来解决此问题,但这不是首选,因为它在功能上并不相同 - 最好让音频接口进行缩放(特别是对于涉及前置放大器的输入)。
I am trying to fix an Audacity bug that revolves around portmixer. The output/input level is settable using the mac version of portmixer, but not always in windows. I am debugging portmixer's window code to try to make it work there.
Using IAudioEndpointVolume::SetMasterVolumeLevelScalar to set the master volume works fine for onboard sound, but using pro external USB or firewire interfaces like the RME Fireface 400, the output volume won't change, although it is reflected in Window's sound control panel for that device, and also in the system mixer.
Also, outside of our program, changing the master slider for the system mixer (in the taskbar) there is no effect - the soundcard outputs the same (full) level regardless of the level the system says it is at. The only way to change the output level is using the custom app that the hardware developers give with the card.
The IAudioEndpointVolume::QueryHardwareSupport function gives back ENDPOINT_HARDWARE_SUPPORT_VOLUME so it should be able to do this.
This behavior exists for both input and output on many devices.
Is this possibly a Window's bug?
It is possible to workaround this by emulating (scaling) the output, but this is not preferred as it is not functionally identical - better to let the audio interface do the scaling (esp. for input if it involves a preamp).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你所说的卡——比如RME——根本不支持通过软件设置主控或任何其他级别,并且你对此无能为力。这不是 Windows 错误。有人可能会说,返回 ENDPOINT_HARDWARE_SUPPORT_VOLUME 是一个错误,但这可能源于驱动程序级别,而不是 Windows 本身。
到目前为止,我发现的唯一解决方案是将调试器(或添加 dll 挂钩)连接到供应商提供的软件,并查看它进行的 DeviceIOControl 调用(这些是用于与硬件通信的调用) )同时在供应商软件中设置音量。对每张卡做到这一点相当困难,但对几张专业卡来说可能值得这样做。特别是对于 Audacity,对于开源音频软件来说,它实际上并没有那么糟糕,所以我可以想象如果可以通过它来设置卡上的音量,有些人会非常高兴。 (当时我们专门使用 RME Multiface,我花了相当多的时间来弄清楚 DeviceIOControl 调用,但最终这绝对是值得的,因为我可以为矩阵中的任何点设置以 dB 为单位的音量)
The cards you talk about -like the RME- ones simply do not support setting the master or any other level through software, and there is not much you can do about it. This is not a Windows bug. One could argue that giving back ENDPOINT_HARDWARE_SUPPORT_VOLUME is a bug though, but that likely originates from the driver level, not Windows itself.
The only solution I found so far is hooking up a debugger (or adding a dll hook) to the vendor supplied software and looking at the
DeviceIOControl
calls it makes (those are the ones used to talk to the hardware) while setting the volume in the vendor software. Pretty hard to do this for every single card, but probably worth doing for a couple of pro cards. Especially for Audacity, for open source audio software it's actually not that bad so I can imagine some people being really happy if the volume on their card could be set by it. (at the time we were exclusively using an RME Multiface I spent quite some time in figuring out the DeviceIOControl calls, but in the end it was definitely worth it as I could set the volume in dB for any point in the matrix)