Obtaining Audio Device GUIDs

Feb 1, 2013 at 2:44 PM
Hi All,
I'm trying to get the GUID for the system audio devices. The best NAudio API I could find is...

MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
MMDeviceCollection devEnum = DevEnum.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active);
 
 foreach (var item in devEnum)
 {
      string devId = item.ID;
 } 
So devId is in this format
{0.0.1.00000000}.{6864ba9c-b9a7-45cd-80d8-ee334575590c}
ie. Two bracketed strings separated by a dot {4-tuple-number}.{GUID}

Questions,
1) Can I depend on the format always being returned in this format so I can reliably parse it? On all OS versions (XP/vista/7/8)?

2) What is the meaning for the 4 digits in the 4-tuple number?

Note: I am a newbie to NAudio. Hats off to the developers!! You guys are Awesome!!
Is there an API guide for NAudio?
Coordinator
Feb 1, 2013 at 2:56 PM
hi, this part of NAudio is really a fairly thin wrapper around the Windows Core Audio APIs, so the documentation you really want is MSDN. The ID property returns the value of the IMMDevice.GetId method which returns an Endpoint ID string.
Feb 1, 2013 at 5:02 PM
Thanks Mark. I appreciate the reply.

I looked at those MSDN API pages (pretty gorpy explanations) but thanks for the link.

What I need to do is to determine which audio devices are "Speakers". Because the MMDeviceCollection includes both speakers and microphones. The device FriendlyName prefixes with the word "Speakers" but I assume that is dependent on the uses language -- it might say "Altavoz" in Spain instead of "Speakers".

I wonder if the 4-Tuple indicate speakers? In my computer devices, speakers have this tuple {0.0.0.00000000} and Microphones and the Mixer have {0.0.1.00000000}

I couldn't find any description of that 4-Tuple in the MSDN documentation.

MMDeviceCollection for my computer
Name=Speakers (Realtek High Definition Audio) DevId={0.0.0.00000000}.{73d4795c-5a20-4a6d-80ef-6b86e31ea1f1}; 

Name=Speakers (2- C-Media USB Audio Device   ) DevId={0.0.0.00000000}.{e2e6b090-3cc4-49d2-a2fb-a5d345c68f1e}; 

Name=Microphone (2- C-Media USB Audio Device   ) DevId={0.0.1.00000000}.{0fcb87d4-1a64-4afa-ace9-9444e61b3baf}; 

Name=Microphone (Realtek High Definition Audio) DevId={0.0.1.00000000}.{43b789c5-e9e7-4912-8a23-79e28f66966e}; 

Name=Stereo Mix (Realtek High Definition Audio) DevId={0.0.1.00000000}.{6864ba9c-b9a7-45cd-80d8-ee334575590c}; 
Coordinator
Feb 4, 2013 at 11:12 AM
You are enumerating all endpoints. Try just asking for Render or Capture devuces. Use DataFlow.Render or DataFlow.Capture

Mark
Feb 4, 2013 at 2:45 PM
Thank you Mark, that helped a lot.