Click here to Skip to main content
15,940,550 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a code to mute microphone (Windows) changing the level for 0. I need to mute the microphone only for my app (a voip softphone based in Sipek sdk) to use the microphone with other apps at the same time.

How can I do that with c#?

Thanks and best regards!

What I have tried:

This is current code:

<pre>NAudio.CoreAudioApi.MMDeviceEnumerator MMDE = new NAudio.CoreAudioApi.MMDeviceEnumerator();
                NAudio.CoreAudioApi.MMDeviceCollection DevCol = MMDE.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.All);

                foreach (NAudio.CoreAudioApi.MMDevice dev in DevCol)
                        if (dev.State == NAudio.CoreAudioApi.DeviceState.Active && (dev.FriendlyName.ToLower().Contains("microfone") || dev.FriendlyName.ToLower().Contains("microphone")))
                            MicFound = true;
                            MicVolume = dev.AudioEndpointVolume.MasterVolumeLevelScalar;

                            var newVolume = (float)Math.Max(Math.Min(level, 100), 0) / (float)100;

                            dev.AudioEndpointVolume.MasterVolumeLevelScalar = newVolume;
                            dev.AudioEndpointVolume.Mute = level == 0;
                    catch (Exception ex)
[no name] 13-Jan-21 10:28am    
"Muting the mic for just your app" ... Isn't that the same as "ignoring" the mic (in your app).
EduardoAngelim 13-Jan-21 10:44am    
Do you have any suggestion?
[no name] 13-Jan-21 12:07pm    
Maybe you're confusing the mic with speaker output.
EduardoAngelim 13-Jan-21 12:14pm    
Tell me more about it, please. Whats is the difference and how can I handle that with c#?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900