Search code examples
c#naudionaudio-framework

For microphone devices NAudio is not providing "Device Number"


I'm using NAudio to record audio from multiple microphone devices, but the problem is, to assign the device I have to provide device number (in WaveIn object), which is unknown.

WaveIn _waveInMicrophone = new WaveIn
                {
                    DeviceNumber = ???,
                    WaveFormat = new WaveFormat(8000, 16, 1)
                };

How to get the Device Number so that i can uniquely assign device to my WaveIn object?


Solution

  • They just start from 0. Use WaveIn.DeviceCount to find out how many devices there are. Use WaveIn.GetCapabilities to find out a bit more about each one (including device name)