USB Headset Microphone Mute Button not Synchronized with System Device Microphone Mute Checkbox in Both Directions RRS feed

  • Question

  • I have a Dell Inspiron 3650 desktop running Microsoft Windows 10 Pro Version 10.0.18363 Build 18363.

    I am trying to use NAudio to mute and unmute my USB headset microphone programmatically using MicrophoneDevice.AudioEndpointVolume.Mute = True or MicrophoneDevice.AudioEndpointVolume.Mute = False

    I ran into the problem of the USB device not synchronized to the system device driver.  I used to be able to use the Win32 API back in the Windows XP days and don't recall this being a problem.  When Windows 7 came out the entire Mixer design for Windows took a turn for worst, Direct-X Mixer functionality was gone forever and this problem was the result.


    Can anyone give an example in Visual Studio 2017 or 2019 C# or VB .net that can make the USB Mic mute button and the OS mute checkbox operate in sync in both directions.  Remember, that old VB6 API code related to the microphone does not work nor does it apply to the Windows 7-10 OS and device driver designs. 


    I have three different brands of USB Headsets with Microphone and Mute ButtonWired and Wireless all with the same behavior as follows:

    1.  If the Mute checkbox shown below is UNCHECKED and the microphone's mute button on the headset is toggled on and off the microphone is muted by the headset's microphone internal circuitry which does successfully mute the sound to the record capture.
    2. If the Mute checkbox shown below is CHECKED then the Headset's Microphone Mute button no effect what so ever. 

    NOTE: There isn't any Win32 API solution that I can figure out or find to solve this sync problem and apparently NAudio's solution can not address the problem either because the Windows API in it's redesign of the mixer never considered this scenario of bidirectional syncing between the USB device driver and the OS.

    I will try to give an example of how this can be an unsolvable problem the best I can.  I am working on a voice driven program for the blind and I can't expect them to be able to turn off a checkbox in settings no more than I can have a visual queue showing them if the microphone is on or off. The only feedback I can give is sound effects and the computer talking to them.

    Functional Example:

    I am using System.Speech.Synthesis, System.Speech.Recognition and NAudio.

    All of my code works I just need sync the mute. Consider the code below (simplified).

    1. System settings have the mute checkbox unchecked, headset mute button is muted.
    2. User un-mutes the microphone with the headset switch.
    3. User speaks into the microphone and says "Stop Dictation"
    4. The user forgets to quickly mute the microphone with the headset's mute button so that the SpeechRecognition_SpeechRecognized event does not falsely trigger based on the headset's speaker volume being so loud that the microphone picks up the computer talking.
    5. The code wants to mute the microphone while the computer is playing a sound effect and speaking to compensate for the possibility of #4 above.
    6. The code wants to keep the microphone muted until the user un-mutes the microphone with the headset switch.
    7. The code makes it's sound effect and tells the user that the dictation has stopped.
    8. The user no longer has control with the headset's mute button unless he/she manually turns off the mute checkbox in settings.

    Private Sub SpeechRecognition_SpeechRecognized(sender As Object, e As SpeechRecognizedEventArgs) Handles SpeechRecognition.SpeechRecognized MicrophoneDevice.AudioEndpointVolume.Mute = True My.Computer.Audio.Play(SoundsPath & "speaking.wav", AudioPlayMode.Background) ModuleSystemVoice.Speak("Dictation has been stopped" & e.Result.Text, 3) ''''''' If you uncomment the line below the microphone is unconditionally un-muted until

    ''''''' the user mutes it with the headset's mute button but in the mean time background

    '''''''noise in the room could falsely trigger another SpeechRecognition_SpeechRecognized

    '''''''event. '''''''MicrophoneDevice.AudioEndpointVolume.Mute = False End Sub


    Saturday, February 29, 2020 8:33 PM