| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- #Include <string.au3> ; for _StringRepeat function
- #Include <GUIConstants.au3> ; GUI !
- Dim $lpszDevice ; Identifier of an MCI device or device driver.
- Dim $lpszDeviceID ; Identifier of an MCI device.
- ; This identifier or alias is assigned when the device is opened.
- Dim $lpszOpenFlags ; Flag that identifies what to initialize.
- Dim $lpszRequest ; Flag for requesting status information. See table on the web page mentioned above.
- ; Source: http://msdn.microsoft.com/library/en-us/multimed/htm/_win32_the_wait_notify_and_test_flags.asp
- Dim $lpszFlags ; Can be "wait", "notify", or both.
- ; For digital-video and VCR devices, "test" can also be specified.
- Dim $lpszCommand ; mciCommand string to send.
- Dim $lpszReturnString ; information will be returned into this string. Reserve enough space!
- Dim $cchReturn ; Length of returnstring
- Dim $mciError ; mci error code
- ; STEP 1: Open the device we want to monitor
- ; Source: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_open.asp
- ;$lpszDevice = "waveaudio"
- $lpszDevice = "new type waveaudio"
- $lpszOpenFlags = "alias mywave" ; For all possible flags, see table on web page mentioned above.
- $lpszFlags = ""
- $lpszCommand = StringFormat( "open %s %s %s", $lpszDevice, $lpszOpenFlags, $lpszFlags );
- $lpszReturnString = _StringRepeat( " ", 100 ) ; Information will return in this string
- $cchReturn = StringLen($lpszReturnString)
- ; Size, in characters, of the return buffer specified
- ; by the lpszReturnString parameter.
- $mciError = _mciSendString( $lpszCommand, $lpszReturnString, $cchReturn, 0);
- if $mciError[0] <> 0 then _mciShowError($mcierror[0])
- ; STEP 2: Obtain the audio levels
- ; Source: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_status_mm.asp
- $lpszDeviceID = "mywave"
- $lpszRequest = "level" ; Returns the current PCM audio sample value.
- ; See table on web page mentioned above.
- $lpszFlags = ""
- $lpszCommand= StringFormat( "status %s %s %s", $lpszDeviceID, $lpszRequest, $lpszFlags );
- ; Before we collect the information, first create a nice GUI.
- GUICreate("MCI wave level test",200,130) ; This will create a centered dialog box
- $VolumeLabel=GUICtrlCreateLabel ("Initializing..." , 14, 8, 200, 20)
- $ProgressBar = GUICtrlCreateProgress (14,25,180,20)
- $ExitButton =GUICtrlCreateButton (" Exit ",80,60)
- GUISetState () ; Display the dialog
- ; Run the GUI until the dialog is closed
- While 1
- $mciError = _mciSendString( $lpszCommand, $lpszReturnString, $cchReturn, 0);
- if $mciError[0] <> 0 then _mciShowError($mcierror[0])
- ; The average input signal level is returned.
- ; The left-channel value is in the high-order word and the right-
- ; or mono-channel value is in the low-order word.
- ; The input level is represented as an unsigned value.
- ; For 8-bit samples, this value is in the range 0 through 127 (0x7F).
- ; For 16-bit samples, it is in the range 0 through 32,767 (0x7FFF).
- GUICtrlSetData ($VolumeLabel, $mcierror[2])
- GUICtrlSetData ($ProgressBar,$mcierror[2])
- $msg = GUIGetMsg()
- Select
- case $msg = $Exitbutton
- Exit
- case $msg = $GUI_EVENT_CLOSE
- Exit
- EndSelect
- Wend
- GUIDelete()
- exit
- ; USER DEFINED FUNCTIONS
- Func _mciSendString( $lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback)
- ;VB-style declaration:
- ;
- ;Declare Function mciSendString
- ; Lib "winmm.dll"
- ; Alias "mciSendStringA"
- ; (ByVal lpstrCommand As String,
- ; ByVal lpstrReturnString As String,
- ; ByVal uReturnLength As Long,
- ; ByVal hwndCallback As Long)
- ; As Long
- ; mciSendString returns information in the lpszReturnString parameter of mciSendString.
- ; The information is dependent on the request type.
- Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0)
- EndFunc
- Func _mciShowError($mcierror)
- ; To show a "readable" mci error.
- ;
- ;VB-style declaration:
- ;
- ;Declare Function mciGetErrorString
- ; Lib "winmm.dll"
- ; Alias "mciGetErrorStringA"
- ; (ByVal dwError As Long,
- ; ByVal lpstrBuffer As String,
- ; ByVal uLength As Long)
- ; As Long
- Dim $errStr ; Error message
- $errStr=_StringRepeat( " ", 100 ) ; Reserve some space for the error message
- $Result=DllCall("winmm.dll","long", "mciGetErrorStringA", "long", $mcierror, "string", $errStr, "long", StringLen($errStr))
- MsgBox (0,"MCI test", "MCI Error Number " & $mcierror & ":" & $Result[2] )
- EndFunc
|