Detect that audio interface is external

Does anyone know how to detect if an audio device is on an external interface (USB, firewire) in Windows?

See here, from Microsofts’ Core Audio API documents:

Basically, you:

  • Enumerate audio devices using IMMDeviceEnumerator.
  • For each device, open its IPropertyStore to access properties.
  • Check the DEVPKEY_Device_Interface or DEVPKEY_Device_BusTypeGuid to determine if the device is on a USB or FireWire interface.

See the code in $JUCE/modules/juce_audio_devices/native/juce_WASAPI_windows.cpp for more clues .. and one or two places you could extend things to add USB/Firewire detection. (JUCE v7.0.13)

Thanks for this. I’d actually gone down this path and was reading out any device property I could find, but the BusTypeGuid never popped up.

Yeah, this is a bit thorny, alas .. see also this note from Microsoft about using this key in older versions of Windows:

It would be cool to see the “Bus Type” exposed in JUCE somehow … for some cases its quite useful to differentiate between whether the user is accessing built-in audio or usb/firewire/whatever-based audio ..

For reasons which will remain eternally mysterious, I couldn’t get this working - mainly because I couldn’t find DEVPKEY_Device_Interface anywhere. Eventually I got a working solution using the SetupDI interface, particularly SetupDiGetDeviceRegistryProperty with parameter SPDRP_DEVICEDESC, and then scanning the result for “USB” or “Firewire”. Absolutely awful compared to the way you do this on MacOS.

Alas, there are two approaches that need to be taken to be able to use this, depending on Windows version.

Did you see the docs here?

I looked at whether I could share my code for this, but alas I cannot .. however, similar code can be found if you search GitHub for the key ..