This project has moved. For the latest updates, please go here.

How to get WaveIn DeviceNumber?

Dec 11, 2012 at 7:48 PM

We are using Naudio (1.5) in a C# application. We plug in 3-5 USB microphone in an WIndows 7 machine to make recording. When using WaveIn, we need to give it the index number for the USB devices that plugged in.

waveIn = new WaveIn();

waveIn.DeviceNmber = xxxxx;

......

My question is: how to get device number for each USB microphone we are using?

Thanks a lot

 

Coordinator
Dec 12, 2012 at 6:48 AM

You can enumerate the available WaveIn devices using WaveIn.GetCapabilities passing in numbers up to WaveIn.DeviceCount

Dec 12, 2012 at 11:03 AM

Thanks for your reply, so if i do this

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

the waveInDevice is the devicenumber for each device.

waveIn = new WaveIn();

waveIn.DeviceNmber = waveInDevice;

Thanks

 

Coordinator
Dec 12, 2012 at 11:04 AM

that's right. It's an index, and 0 always is your default audio device

Dec 12, 2012 at 11:13 AM

Thanks!!

Dec 12, 2012 at 11:33 AM

I plugged 2 USB microphones in front of my machine and 1 in the back. The one in the back (Microphone (3-USB Audio Device) has index 0, so this is the default audio device.

Thanks