Click here to Skip to main content
15,897,371 members

Audio output level as value

ramakrishnan Madhavna asked:

Open original thread
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>
Tags: VBA

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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