Click here to Skip to main content
Rate this: bad
good
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.

Code:
#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 11-Dec-12 1:46am
Edited 11-Dec-12 2:27am
(no name)130.2K
v3

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

  Print Answers RSS
0 Sascha Lefévre 490
1 Sergey Alexandrovich Kryukov 413
2 Maciej Los 210
3 Abhinav S 205
4 Richard Deeming 170
0 Sergey Alexandrovich Kryukov 6,928
1 OriginalGriff 6,381
2 Maciej Los 2,782
3 Abhinav S 2,732
4 Peter Leow 2,694


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2015
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