[python-win32] Unmuting the Microphone

Tim Roberts timr at probo.com
Mon Nov 9 20:09:07 CET 2009


Mike Driscoll wrote:
>
> I received a request to un-mute the microphone on Windows XP. I've
> looked around online and all I've seen are people recommending ctypes,
> but no examples (in Python). I did find this C++ code, but I can't
> tell if if just toggles mute or allows the programmer to specify that
> they want the mic unmuted. Here's the link:
> http://www.associatedcontent.com/article/1171176/how_to_mute_or_unmute_the_system_volume.html?cat=59
>

That one only works in Vista and Win 7.  XP doesn't support IMMDevice.


> I found an even longer piece of c# code, but it looks like it's mostly
> constants:
>
> http://blog.xploiter.com/c-and-aspnet/muting-audio-channels-mixer-control-api/
>

That uses the WinMM APIs, which is the right way to go on XP.  The
constants are already defined in win32.mmsystem, but I don't think the
APIs themselves are.  That means falling back to ctypes.  This C++
example is closer:
   
http://stackoverflow.com/questions/1042423/how-do-i-get-the-mic-volume-of-all-audio-cards-in-windows-xp-using-c

You'll call mixerOpen for your waveIn device (probably #0), call
mixerGetLineInfo to make sure it's a microphone, then enumerate the
controls to find the mute, and mixerSetControlDetails to clear the mute
state.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list