Click here to Skip to main content
12,816,490 members (33,590 online)
Rate this:
Please Sign up or sign in to vote.
See more: VBA
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.

#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()

		case $msg = $Exitbutton

		case $msg = $GUI_EVENT_CLOSE 



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

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


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

Posted 11-Dec-12 1:46am

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100