This project has moved and is read-only. For the latest updates, please go here.

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
ie. Two bracketed strings separated by a dot {4-tuple-number}.{GUID}

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?
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 {} and Microphones and the Mixer have {}

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={}.{73d4795c-5a20-4a6d-80ef-6b86e31ea1f1}; 

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

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

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

Name=Stereo Mix (Realtek High Definition Audio) DevId={}.{6864ba9c-b9a7-45cd-80d8-ee334575590c}; 
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

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