Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to find output sound level in the vmeter using VB code. can you please help me to get the same..

The below code is used to find the inpput sound level (mic sound level). But i want to find the output sound level (speaker phone). Please help me to get resolved.

Code:
C++
#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.


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

$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])


$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 );


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

While 1

	$mciError = _mciSendString( $lpszCommand,  $lpszReturnString,  $cchReturn, 0);

	if $mciError[0] <> 0 then _mciShowError($mcierror[0])

	GUICtrlSetData ($VolumeLabel, "Current wave level is: " & $mcierror[2])
	GUICtrlSetData ($ProgressBar,$mcierror[2])

	$msg = GUIGetMsg()

	Select
		case $msg = $Exitbutton
    			Exit

		case $msg = $GUI_EVENT_CLOSE 
			Exit
	EndSelect
Wend

GUIDelete()

exit



Func _mciSendString( $lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback)

Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0)

EndFunc


Func _mciShowError($mcierror)

 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</guiconstants.au3></string.au3>
Posted
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900