How can I programmatically control the Microphone and Microphone Boost settings in Win7 from C#?

橙三吉。 提交于 2019-12-20 07:28:05

问题


Windows 7 has some new audio settings which I haven't been able to control from my C# application. Specifically, within the Input (microphone) properties, there is a Levels Tab containing Microphone and Microphone Boost sliders, and a Microphone mute toggle / checkbox.

I need to programatically ensure that the Microphone is not muted--but have not found the necessary APIs to either read or set the values.


回答1:


I was unable to find an API that provided control over these specific volume levels. Please add new answers if they are available and I'll gladly accept a working solution.




回答2:


You can use a very useful library built around windows mixer by Caster Tiu from http://www.codeproject.com/KB/audio-video/AudioLib.aspx?msg=1323850

According to documentation on this page:

Specific controls like Fadder, Microphone Boost, bass, treble, etc. can be accessed via the MixerControl object using ValueAsSigned, ValueAsUnsigned and ValueAsBoolean properties, but they are not implemented as standard properties because they don't belong to all controls.




回答3:


There is a WalkTreeBackwardsFromPart sample that shows how to enumerate audio endpoints and print out their current volume, You can modify the code to unmute the analog mixer via IDeviceTopology

Windows should unmute the software volume at the beginning of a capture session, does your device have a hardware volume?




回答4:


The IAudioEndpointVolume interface might work for you. It has functions to get/set mute state and volume levels for a recording or playback device.

Reference: http://msdn.microsoft.com/en-us/library/windows/desktop/dd370892(v=vs.85).aspx



来源:https://stackoverflow.com/questions/8440588/how-can-i-programmatically-control-the-microphone-and-microphone-boost-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!