Win7: Get microphone mute status

1.1k Views Asked by At

my main goal is to have a program, that allows me to mute/unmute my microphone under windows using the 'scroll lock' key. This would give me a nice indicator for whether the mic is muted or not because of the scroll lock light on my keyboard.

How can I get information about the status of the microphone - whether it's muted or not? Any dll I could call to achieve this?

Thanks

1

There are 1 best solutions below

0
On

Use CoreAudioApi. You can find dll here. Find your microphones with this function:

  private List<MMDevice> gMicrophoneDevices = new List<MMDevice>();//global variable
  private bool findMicrophones()
        {
            MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
            MMDeviceCollection devices = DevEnum.EnumerateAudioEndPoints(EDataFlow.eCapture, EDeviceState.DEVICE_STATE_ACTIVE);
            for (int i = 0; i < devices.Count; i++)
            {
                MMDevice deviceAt = devices[i];
                if (deviceAt.FriendlyName.ToLower() == "microphone" || deviceAt.FriendlyName.ToLower() == "микрофон")//you can add more languages here
                    gMicrophoneDevices.Add(deviceAt);                
            }
            if (gMicrophoneDevices.Count == 0)
                return false;
            else return true;
        }

After microphone device found, use this to get its mute status:

gMicrophoneDevices[0].AudioEndpointVolume.Mute

If its true, then your first microphone is muted.