使用 winmm.dll 时,什么决定了 Windows 中声音设备的顺序?

发布于 2024-08-06 13:56:12 字数 257 浏览 5 评论 0原文

我正在尝试使用 NAudio 创建多个声音输出应用程序。我们安装了 8 个 USB 声卡。 NAudio 让我使用全部 8 个,但我无法找出确定哪个设备索引是哪个卡的模式。

这些卡将连接到不同的硬件,因此确保您知道您正在使用哪张卡非常重要。

我一直在尝试使用 WMI 来轮询信息,但我似乎找不到任何确定声音设备顺序的信息。

更新: 我忘记包含有关此问题的一些信息。声卡都是通过 12 端口集线器连接的 USB 声卡。

I am trying to use NAudio to create a multiple sound output application. We have 8 USB sound cards installed. NAudio lets me use all 8 but I can't figure out a pattern for determining which device index is which card.

The cards will be hooked up to different hardware so it is important to make sure you know which card you are using.

I have been trying to use WMI to poll for the information but I can't seem to locate any information that determines the order of the sound devices.

Update:
I forgot to include some information about this problem. The sound cards are all USB sound cards hooked up through a 12 port hub.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

十年不长 2024-08-13 13:56:12

对于所有版本的 Windows 来说,设备的顺序都是不确定的。对于 Vista 及更高版本,设备通常按 DSound GUID(或多或少)排序,因此它们实际上是随机的。

The order of devices is non deterministic for all versions of Windows. For Vista and above, the devices are typically ordered by the DSound GUID (more-or-less) so they're effectively random.

牛↙奶布丁 2024-08-13 13:56:12

我假设你正在使用 WaveOut?您可以调用 WaveOut.GetCapability(deviceNumber) 来获取设备的名称,这可能会对您有所帮助。

I'm assuming you are using WaveOut? You can call WaveOut.GetCapabilities(deviceNumber) to get hold of the name of the device, which might help you out.

单调的奢华 2024-08-13 13:56:12

这是我到目前为止所想出的,它对我们有用。

使用 WMI,您可以从 Win32_SoundDevice 获取 DeviceID。然后使用它可以访问位于 HKLM\SYSTEM\CurrentControlSet\ENUM\'DeviceID' 的寄存器并获取名为“Driver”的字符串值。该值包含 ClassGUID 以及末尾的数字。

示例:{4d36e96c-e325-11ce-bfc1-08002be10318}\0015

如果您去掉所有声音设备的最后一个数字*(15)*并对它们进行排序,这就是NAudio 中列出了使用 winmm.dll 的设备。这些声音设备也有一个位置,可以在注册表中的同一键下,也可以使用 DeviceID 从 Win32_PNPEntity 中找到。

在我们的例子中,位置让我们可以确定声音设备插入到 USB 集线器的哪个端口。

This is what I have come up with so far and it works for us.

Using WMI you can get the DeviceID from Win32_SoundDevice. Then using that you can access the registery at HKLM\SYSTEM\CurrentControlSet\ENUM\'DeviceID' and get the string value named "Driver". This value contains the ClassGUID plus a number at the end.

Example: {4d36e96c-e325-11ce-bfc1-08002be10318}\0015

If you strip off that last number*(15)* for all of you sound devices and order them, that is the order that the devices are listed from NAudio with uses winmm.dll. There is also a location for these sound devices, either in the registery at the same key or from Win32_PNPEntity using the DeviceID.

In our case the location lets us determine which port of the USB hub that sound device is plugged into.

永不分离 2024-08-13 13:56:12

看看这篇 MSDN 文章。它使用 DirectSound 枚举音频设备:

http:// msdn.microsoft.com/en-us/library/bb318674(VS.85).aspx

Have a look at this MSDN article. It uses DirectSound to enumerate the audio devices:

http://msdn.microsoft.com/en-us/library/bb318674(VS.85).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文