2

As the title says I'd like to check if my microphone is muted. Or even better get an event if it gets muted/unmuted.

I tried to get some information form the internet. Turns out I simply don't get it. I found out about the "new" Audio Core API which gave me some ideas, sadly I did not find any c# code so I cant figure out how to use any of this.

With the following code I could get some information for my microphone, however nothing changes if I mute it.

    ManagementObjectSearcher objSearcher = new ManagementObjectSearcher(
                "SELECT * FROM Win32_SoundDevice");

            ManagementObjectCollection objCollection = objSearcher.Get();
            ManagementObject rodeMic = null;

            foreach (ManagementObject obj in objCollection)
            {
                foreach (PropertyData property in obj.Properties)
                {
                    if (property.Name == "DeviceID" && (string) property.Value == "USB\\VID_...")
                    {
                        rodeMic = obj;
                    }
                }
            }

            if (rodeMic != null)
            {
                foreach (var property in rodeMic.Properties)
                {
                    Console.Out.WriteLine(String.Format("{0}:{1}", property.Name, property.Value));
                }
            }
2
  • The only thing above I can see is just grabbing some properties. Can you provide us something to go on with what you have tried and what is not working.
    – Trevor
    Sep 5, 2019 at 18:06
  • The above works, the only issue I can see is you may have the device ID value wrong in your if statement.
    – DCCoder
    Sep 5, 2019 at 18:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.