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

selecting default recording device

Apr 20, 2011 at 7:50 PM

I am working on a project that records sounds from the microphone and processes the buffer.  I am using WaveIn to capture the audio.

I have two questions.

When I use an external connected microphone, my app response was really good. When I use the laptop microphone the response was really bad. I have to manually increase the volume and boost of the mic.

1) I am trying to figure out in the code to find whether there is a external microphone connected?

 If there is, I want to set that as default device and set its volume and boost accordingly. If there is no external microphone, I want to set the laptop microphone to default device and set its properties. Window is not setting the default device on its own (which is wierd). I have to set manually in windows all these settings.

I am setting the volume as follows

 var mixerLine = new MixerLine((IntPtr)DeviceNumber, 0, MixerFlags.WaveIn);
                foreach (var control in mixerLine.Controls)
                    if (control.ControlType == MixerControlType.Volume)
                        volumeControl = control as UnsignedMixerControl;
                        if (volumeControl != null)
                            volumeControl.Percent = desiredVolume;


So once I figure out the device number of the defaut device, then I can set the volume.

how do I set the boost?

Thanks much in advance.

Apr 21, 2011 at 12:43 PM

it is unfortunately very hard to find the volume control of the default microphone in a way that is reliable on both XP and Vista/Win 7. My best effort at this can be found in the .NET voice recorder project (, but even that isn't quite right

Apr 21, 2011 at 9:13 PM

Understood. Is there a way to set the microphone boost (dB). I tried the MixerControl.Decibal. But that didn't work.


Apr 21, 2011 at 9:30 PM

You'll be looking for a boolean control in the mixerline controls. Just an advance warning though, can't remember if setting boolean mixer controls is supported (that code is about 10 years old!)