I have this command that builds a script to mute the input volume. The input volume is not fully muted, though. It seems to be closer to 10% than 0%.
osacompile -x -e 'tell application "System Events" to set volume input volume 0' -o ~/bin/mute_mic.scpt
This is odd, because the slider bar is as far left as it can go, but as you can see from the attached image, sound still is registering. However, if I use the mouse to click on the slider at zero, then it does actually mute the input.
Why does this happen? Am I using applescript improperly here?
I can even replicate this with the basic AppleScript Editor, so I know it's not a problem with the compilation.
(Note: I originally took my cue for the solution to this problem from this question's answer.)
Best Answer
As far as I can tell, the script works as expected, the problem is in the OS X audio input code. When I run it, the slider goes to 0%, verified by mousing over the slider until the tooltip appears:
This is the same as if I drag the volume slider manually.
The problem is seemingly that "0%" doesn't actually mean off, but rather a very low threshold. In some quick testing, I could record the sound of my finger tapping on my MacBook Pro's casing near the mic (on most machines I believe it's around the right speaker grill) when the volume was set to 0. I could replicate that regardless of whether I set the slider manually or via AppleScript. It did seem to be low enough that virtually any other sound isn't picked up, but clearly the microphone isn't truly off.
As far as I can tell, there's no way to properly mute the built-in mic. The best I can suggest is changing the audio input to use the line in, if your Mac is equipped with a line in port. Doing that via AppleScript requires some GUI scripting unfortunately, but this should do it (source):
If you have more than the two standard audio inputs (Mic and Line In), you may need to change the number in
row 2
to whichever is appropriate, according to the order in your Input preferences.