List recorders in NAudio

How can you get a list of all recording devices on a computer using NAudio? When you want to record, you must give it the index of the device you want to use, but there is no way to find out which device it is. I would like to be able to choose from Mic, Stereo Mix, etc.

+5
source share
1 answer

For WaveIn, you can use the static WaveIn.GetCapabilities method. This will give you the device name, but with an annoying restriction of no more than 31 characters. I'm still looking for a way to get the full name (see My question here ).

int waveInDevices = WaveIn.DeviceCount;
for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
{
    WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
    Console.WriteLine("Device {0}: {1}, {2} channels", waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
}

WASAPI (Vista ) MMDeviceEnumerator:

MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
foreach (MMDevice device in enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.All))
{
    Console.WriteLine("{0}, {1}", device.FriendlyName, device.State);
}

WaveIn, .

+17

All Articles