qq490405 发表于 2010-5-16 13:57:27

au3如何把录音控制的音量调到最大

本帖最后由 qq490405 于 2010-7-13 09:23 编辑

如是说,麦克风的音量太小了,怎么样用AU3来实现调动音量大小

lynfr8 发表于 2010-5-17 00:12:21

本帖最后由 lynfr8 于 2010-5-17 00:43 编辑

解压附件,得到volumeline.exe
运行
RunWait(@ComSpec & ' /c "' & @ScriptDir & '\volumeline.exe" GET:ALL > audiotemp.txt', @ScriptDir, @SW_HIDE)
产生一个文档audiotemp.txt
内容如图:

获取到主要参数(例如红框部分)


例子:

1.将红框3麦克风音量调为最大100,代码格式为
RunWait("volumeline.exe SET:" & $MixerId & ":" & $GroupId & ":" & $ControlId & " VOLUME:<0-100>", @ScriptDir, @SW_HIDE)
即:
RunWait("volumeline.exe SET:" & '0' & ":" & '0' & ":" & '10' & " VOLUME:100", @ScriptDir, @SW_HIDE)

2.麦克风静音,代码格式为
VolumeLine.exe SET:<MixerId>:<GroupId>:<ControlId> MUTE:<ON|OFF>
即:
RunWait("volumeline.exe SET:" & '0' & ":" & '0' & ":" & '10' & " MUTE:ON", @ScriptDir, @SW_HIDE)

3.恢复非静音:
RunWait("volumeline.exe SET:" & '0' & ":" & '0' & ":" & '10' & " MUTE:OFF", @ScriptDir, @SW_HIDE)

其他功能未测试,自行研究吧



官网传送门(缺钱的兄弟就到这里拿吧):
http://www.autoitscript.com/forum/index.php?showtopic=63631&st=0&p=478945&hl=microphone%20&fromsearch=1&#entry478945

离我远点 发表于 2010-5-17 00:32:19

下载了,也运行了,但是并没有出现你所说的audiodevices.txt这个文件。。。。

lynfr8 发表于 2010-5-17 00:44:41

下载了,也运行了,但是并没有出现你所说的audiodevices.txt这个文件。。。。
离我远点 发表于 2010-5-17 00:32 http://www.autoitx.com/images/common/back.gif


已修改,请阅2搂原帖开头部分

menfan 发表于 2010-5-17 09:36:41

呵呵好东西要收藏。。

kxing 发表于 2010-5-17 10:12:57

感谢了,拿下以后用...

kxing 发表于 2010-5-17 10:13:07

感谢了,拿下以后用......

seeking 发表于 2010-5-17 23:00:55

好强啊,谢谢分享出来
学习下

nmgwddj 发表于 2010-6-23 22:01:53

回复 4# lynfr8


    AC97声卡选择不能选择录音设备。select:on这个参数貌似是没有

nmgwddj 发表于 2010-6-23 22:03:12

回复 4# lynfr8


   解决了 后边不带参数就OK了

pc1436 发表于 2024-9-11 17:23:31

; adapted from DanyFirex and xMatz code #include <GuiConstants.au3> #include <Constants.au3>Global Const $S_OK = 0 Global Enum $eRender, $eCapture Global Enum $eConsole, $eMultimedia, $eCommunicationsGlobal Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _   "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _   "GetDevice hresult(wstr;ptr*);" & _   "RegisterEndpointNotificationCallback hresult(ptr);" & _   "UnregisterEndpointNotificationCallback hresult(ptr);"Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $tagIMMDevice = "Activate hresult(clsid;dword;variant*;ptr*);" & _   "OpenPropertyStore hresult(dword;ptr*);" & _   "GetId hresult(ptr*);" & _   "GetState hresult(dword*);"Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" Global Const $tagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _   "GetMeteringChannelCount hresult(dword*);" & _   "GetChannelsPeakValues hresult(dword;float*);" & _   "QueryHardwareSupport hresult(dword*);"Global $oAudioMeterInformation = _MicVolObject() If Not IsObj($oAudioMeterInformation) Then Exit MsgBox ($MB_SYSTEMMODAL,"Error","Unable to mic audio meter")Global $hGUI = GUICreate("", 80, 300, -1, -1, $WS_BORDER + $WS_POPUP) Global $hControl = GUICtrlCreateProgress(20, 20, 40, 260, $PBS_VERTICAL)AdlibRegister("_LevelMeter", 45)GUISetState()While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd AdlibUnRegister()Func _LevelMeter()   Local $iPeak   If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then   $iCurrentRead = 100 * $iPeak   GUICtrlSetData($hControl, $iCurrentRead)   If $iCurrentRead Then ConsoleWrite($iCurrentRead & @CRLF)   EndIf EndFunc   ;==>_LevelMeterFunc _MicVolObject()   Local Const $CLSCTX_INPROC_SERVER = 0x1    Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator)   If @error Then Return SetError(1, 0, 0)    Local $pDefaultDevice   $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eCapture, $eConsole, $pDefaultDevice)   If Not $pDefaultDevice Then Return SetError(2, 0, 0)    Local $oDefaultDevice = ObjCreateInterface($pDefaultDevice, $sIID_IMMDevice, $tagIMMDevice)   If Not IsObj($oDefaultDevice) Then Return SetError(3, 0, 0)    Local $pAudioMeterInformation   $oDefaultDevice.Activate($sIID_IAudioMeterInformation, $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation)   If Not $pAudioMeterInformation Then Return SetError(4, 0, 0)   Return ObjCreateInterface($pAudioMeterInformation, $sIID_IAudioMeterInformation, $tagIAudioMeterInformation) EndFunc   ;==>_MicVolObject; adapted from DanyFirex and xMatz code #include <GuiConstants.au3> #include <Constants.au3>Global Const $S_OK = 0 Global Enum $eRender, $eCapture Global Enum $eConsole, $eMultimedia, $eCommunicationsGlobal Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _   "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _   "GetDevice hresult(wstr;ptr*);" & _   "RegisterEndpointNotificationCallback hresult(ptr);" & _   "UnregisterEndpointNotificationCallback hresult(ptr);"Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $tagIMMDevice = "Activate hresult(clsid;dword;variant*;ptr*);" & _   "OpenPropertyStore hresult(dword;ptr*);" & _   "GetId hresult(ptr*);" & _   "GetState hresult(dword*);"Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" Global Const $tagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _   "GetMeteringChannelCount hresult(dword*);" & _   "GetChannelsPeakValues hresult(dword;float*);" & _   "QueryHardwareSupport hresult(dword*);"Global $oAudioMeterInformation = _MicVolObject() If Not IsObj($oAudioMeterInformation) Then Exit MsgBox ($MB_SYSTEMMODAL,"Error","Unable to mic audio meter")Global $hGUI = GUICreate("", 80, 300, -1, -1, $WS_BORDER + $WS_POPUP) Global $hControl = GUICtrlCreateProgress(20, 20, 40, 260, $PBS_VERTICAL)AdlibRegister("_LevelMeter", 45)GUISetState()While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd AdlibUnRegister()Func _LevelMeter()   Local $iPeak   If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then   $iCurrentRead = 100 * $iPeak   GUICtrlSetData($hControl, $iCurrentRead)   If $iCurrentRead Then ConsoleWrite($iCurrentRead & @CRLF)   EndIf EndFunc   ;==>_LevelMeterFunc _MicVolObject()   Local Const $CLSCTX_INPROC_SERVER = 0x1    Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator)   If @error Then Return SetError(1, 0, 0)    Local $pDefaultDevice   $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eCapture, $eConsole, $pDefaultDevice)   If Not $pDefaultDevice Then Return SetError(2, 0, 0)    Local $oDefaultDevice = ObjCreateInterface($pDefaultDevice, $sIID_IMMDevice, $tagIMMDevice)   If Not IsObj($oDefaultDevice) Then Return SetError(3, 0, 0)    Local $pAudioMeterInformation   $oDefaultDevice.Activate($sIID_IAudioMeterInformation, $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation)   If Not $pAudioMeterInformation Then Return SetError(4, 0, 0)   Return ObjCreateInterface($pAudioMeterInformation, $sIID_IAudioMeterInformation, $tagIAudioMeterInformation) EndFunc   ;==>_MicVolObject; adapted from DanyFirex and xMatz code #include <GuiConstants.au3> #include <Constants.au3>Global Const $S_OK = 0 Global Enum $eRender, $eCapture Global Enum $eConsole, $eMultimedia, $eCommunicationsGlobal Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _   "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _   "GetDevice hresult(wstr;ptr*);" & _   "RegisterEndpointNotificationCallback hresult(ptr);" & _   "UnregisterEndpointNotificationCallback hresult(ptr);"Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $tagIMMDevice = "Activate hresult(clsid;dword;variant*;ptr*);" & _   "OpenPropertyStore hresult(dword;ptr*);" & _   "GetId hresult(ptr*);" & _   "GetState hresult(dword*);"Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" Global Const $tagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _   "GetMeteringChannelCount hresult(dword*);" & _   "GetChannelsPeakValues hresult(dword;float*);" & _   "QueryHardwareSupport hresult(dword*);"Global $oAudioMeterInformation = _MicVolObject() If Not IsObj($oAudioMeterInformation) Then Exit MsgBox ($MB_SYSTEMMODAL,"Error","Unable to mic audio meter")Global $hGUI = GUICreate("", 80, 300, -1, -1, $WS_BORDER + $WS_POPUP) Global $hControl = GUICtrlCreateProgress(20, 20, 40, 260, $PBS_VERTICAL)AdlibRegister("_LevelMeter", 45)GUISetState()While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd AdlibUnRegister()Func _LevelMeter()   Local $iPeak   If $oAudioMeterInformation.GetPeakValue($iPeak) = $S_OK Then   $iCurrentRead = 100 * $iPeak   GUICtrlSetData($hControl, $iCurrentRead)   If $iCurrentRead Then ConsoleWrite($iCurrentRead & @CRLF)   EndIf EndFunc   ;==>_LevelMeterFunc _MicVolObject()   Local Const $CLSCTX_INPROC_SERVER = 0x1    Local $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator)   If @error Then Return SetError(1, 0, 0)    Local $pDefaultDevice   $oMMDeviceEnumerator.GetDefaultAudioEndpoint($eCapture, $eConsole, $pDefaultDevice)   If Not $pDefaultDevice Then Return SetError(2, 0, 0)    Local $oDefaultDevice = ObjCreateInterface($pDefaultDevice, $sIID_IMMDevice, $tagIMMDevice)   If Not IsObj($oDefaultDevice) Then Return SetError(3, 0, 0)    Local $pAudioMeterInformation   $oDefaultDevice.Activate($sIID_IAudioMeterInformation, $CLSCTX_INPROC_SERVER, 0, $pAudioMeterInformation)   If Not $pAudioMeterInformation Then Return SetError(4, 0, 0)   Return ObjCreateInterface($pAudioMeterInformation, $sIID_IAudioMeterInformation, $tagIAudioMeterInformation) EndFunc   ;==>_MicVolObject

laoliao97 发表于 2024-9-13 12:05:55

学习了,au3果然无所不能!
页: [1]
查看完整版本: au3如何把录音控制的音量调到最大