9

I'd like to get full name of all connected microphones. I was googling to find out an answer but there was no answer that satisfies me.

Let me show some examples:

1.

ManagementObjectSearcher mo = new ManagementObjectSearcher("select * from Win32_SoundDevice");

foreach (ManagementObject soundDevice in mo.Get())
{               
    MessageBox.Show(soundDevice.GetPropertyValue("Caption").ToString());  
    // or 
    MessageBox.Show(soundDevice.GetPropertyValue("Description").ToString());  
    //or
    MessageBox.Show(soundDevice.GetPropertyValue("Manufacturer").ToString()); 
    //or 
    MessageBox.Show(soundDevice.GetPropertyValue("Name").ToString());
    //or
    MessageBox.Show(soundDevice.GetPropertyValue("ProductName").ToString());                     
}

All of these getters shows: "Device Audio USB" or "Device compatible with High Definition standard".

2.

WaveInCapabilities[] devices = GetAvailableDevices();        
foreach(device in devices)
{
    MessageBox.Show(device.ProductName);
}

The same answer: "Device Audio USB" or "Device compatible with High Definition standard".

I want to get the full name. I mean, something like: "Sennheiser microphone USB". Is it even possible? I found: Get the full name of a waveIn device but a link in it is broken and I don't see any dsound.lib for c# (to use DirectSoundCaptureEnumerate). Am I missing anything? Or is there any other option?

Community
  • 1
  • 1
Darooks
  • 177
  • 9
  • 2
    Is the full name of your device visible *anywhere* in Windows? (Device manager, etc.) – Heinzi Apr 11 '16 at 07:19
  • @Heinzi No, I don't see the full name of device in Device Manager. Does it mean it is impossible to do? – Darooks Apr 11 '16 at 07:30
  • Well, if Windows does not know the full device name, I don't think that there's a ways to retrieve it. (But I'm no expert on Windows API, so I'd be happy if someone could prove me wrong.) – Heinzi Apr 11 '16 at 07:58
  • I think you are right. I switched USB connector and I have now the name using second example and @AnkurTripathi 's example. – Darooks Apr 11 '16 at 08:16

2 Answers2

5

@AnkurTripathi answer is correct but it returns a name that contains up to 32 characters. If anyone doesn't want this restriction then the best idea is to use an enumarator:

using NAudio.CoreAudioApi;

MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
var devices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active);            
foreach (var device in devices)
    MessageBox.Show(device.friendlyName);

It works perfect for me.

Draken
  • 3,134
  • 13
  • 34
  • 54
Darooks
  • 177
  • 9
3

Try Naudio https://naudio.codeplex.com/

for (int n = 0; n < WaveIn.DeviceCount; n++)
{
    this.recordingDevices.Add(WaveIn.GetCapabilities(n).ProductName);
    comboBoxAudio.Items.Add(WaveIn.GetCapabilities(n).ProductName);
}

for get Full Name(FriendlyName):

MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
foreach (MMDevice device in enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active))
   {
           this.recordingDevices.Add(device.FriendlyName);
   }
Ankur Tripathi
  • 671
  • 9
  • 35
  • There is the same answer as mentioned above. In this example the ProductName has only 31 characters. – Darooks Apr 11 '16 at 07:44
  • @Darooks Is the full name of your device visible anywhere in Windows? - If not - there is no more information available – Cadburry Apr 11 '16 at 08:02
  • @Cadburry I had to change the USB. There is the full name in Device Manager now. I haven't noticed it before. – Darooks Apr 11 '16 at 08:12
  • @AnkurTripathi It is right answer but it returns device name with 31 characters, is it possible to get the name without this restriction? – Darooks Apr 11 '16 at 08:15
  • can you show me what is the device name and what return comes from your code ? its work for me and getting full name – Ankur Tripathi Apr 11 '16 at 08:36
  • @AnkurTripathi The name of my device is: "Sennheiser USB Headset". The code returns: "Microphone ( 2 -- Sennheiser USB" 32 characters. My goal is to get out of this restriction. – Darooks Apr 12 '16 at 07:08