1
votes

I recently began coding a C# program that does simple audio recording via a microphone connected to a PC (i.e. laptop microphone, desktop headset, etc etc...).

So now, I've got everything done like recording, pausing, stopping, saving, and replaying, but I can't seem to code the last feature: muting the microphone. This means that the program continues to record audio, but the recorded data is silence because the microphone is muted and there is no input from the microphone.

I've done some searching and all I found is actually disabling the hardware itself in order to mute it, rather than just cutting input from the microphone hardware.

Can anyone here show me how to stop receiving input from the microphone in C#? And then, restore back to receiving input when selected to do so?

EDIT: I should also say that I'm using winmm.dll as an dll import, like this:

[DllImport("winmm.dll",EntryPoint="mciSendStringA", ExactSpelling=true,
            CharSet=CharSet.Ansi, SetLastError=true)]
private static extern int record(string lpstrCommand, string lpstrReturnString,
                                 int uReturnLength, int hwndCallback);`
1
possible duplicate of Mute microphone on Windows 7 - Kevin D
I don't understand the solution, it has a source code and a .dll library to import(?). How do I go around implementing it? Is the solution the .dll library? Or must I also refer to the source code too? (Take it as there is no mute feature yet in the C# program) - ㅤㅤㅤㅤㅤㅤ

1 Answers

0
votes

If you want to "restore back to receiving input" possibly with the same level settings, it is probably a good idea to not touch the microphine levels and muting setting at all but simply set the incoming samples to zero for the "muted" time interval.

Otherwise you should interact with the Mixer as shown here