What determines the order for sound devices in windows when using winmm.dll?
Asked Answered
B

4

5

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.

Boast answered 1/10, 2009 at 18:6 Comment(0)
D
4

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.

Directional answered 2/10, 2009 at 5:0 Comment(1)
Pretty much what I was thinking but I think I have a hack to figure it out.Boast
B
2

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.

Bandur answered 2/10, 2009 at 6:50 Comment(1)
This would work if they weren't all identical USB sound cards. Sorry I didn't mention that before. Thanks though.Boast
B
2

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.

Boast answered 2/10, 2009 at 16:30 Comment(0)
P
1

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

Peseta answered 1/10, 2009 at 18:40 Comment(1)
Haven't tried this yet because I would have to bring the DirectX assemblies into to the code. I will try this is all else fails.Boast

© 2022 - 2024 — McMap. All rights reserved.