Sign in to follow this  
Followers 0
torun

waveInOpen

1 post in this topic

#1 ·  Posted (edited)

I am trying to get this to work, but the dllcall to waveInOpen returns 11 (MMSYSERR_INVALPARAM). The original pieces are in comments. Must be somewhere the assignments of variable types. A second question: in the msgbox I have to use $mmresult[0] instead of $mmresult, otherwise it won't work, why?

#Include <GUIConstants.au3>

Opt( "GUIOnEventMode", 1 )

Dim $mmResult
Dim $hwavein

Const $WAVE_FORMAT_PCM = 1
Const $WAVE_MAPPER = -1
Const $CALLBACK_NULL = 0

$Form1 = GUICreate("WAVEIN", 281, 197, 193, 115)
$Button1 = GUICtrlCreateButton("Start", 0, 120, 89, 33, 0)
$Button2 = GUICtrlCreateButton("Stop", 96, 120, 89, 33, 0)
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent ( $Button1, "start" )
GUICtrlSetOnEvent ( $Button2, "stop" )
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

;typedef struct { 
;   WORD  wFormatTag; 
;   WORD  nChannels; 
;   DWORD nSamplesPerSec; 
;   DWORD nAvgBytesPerSec; 
;   WORD  nBlockAlign; 
;   WORD  wBitsPerSample; 
;   WORD  cbSize; 
;} WAVEFORMATEX; 

$wf = DllStructCreate("ushort wFormatTag;ushort nChannels;int nSamplesPerSec;dword nAvgBytesPerSec;ushort nBlockAlign;ushort wBitsPerSample;ushort cbSize")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

;wf.wFormatTag = WAVE_FORMAT_PCM;
;wf.nChannels = 1;
;wf.nSamplesPerSec = 8000;
;wf.nAvgBytesPerSec = wf.nSamplesPerSec;
;wf.nBlockAlign = 1;
;wf.wBitsPerSample = 8;
;wf.cbSize = 0;


DllStructSetData($wf,"wFormatTag",$WAVE_FORMAT_PCM)
DllStructSetData($wf,"nChannels",1)
DllStructSetData($wf,"nSamplesPerSec",8000)
DllStructSetData($wf,"nAvgBytesperSec",DllStructGetData($wf,"nSamplesPerSec"))
DllStructSetData($wf,"nBlockAlign",1)
DllStructSetData($wf,"wBitsPerSample",8)
DllStructSetData($wf,"cbSize",0)


;MMRESULT waveInOpen(
;  LPHWAVEIN       phwi,      
;  UINT_PTR    uDeviceID,  
;  LPWAVEFORMATEX pwfx,    
;  DWORD_PTR      dwCallback, 
;  DWORD_PTR      dwCallbackInstance, 
;  DWORD          fdwOpen    
;);

;waveInOpen(&hWaveIn, WAVE_MAPPER, &wf, 0, 0, CALLBACK_NULL);

$mmresult = DllCall("winmm.dll","int","waveInOpen","hwnd",$hwavein,"int",$WAVE_MAPPER,"ptr",DllStructGetPtr($wf),"int",0,"int",0,"int",$CALLBACK_NULL)
msgbox(0,"waveInOpen mmresult",$mmresult[0])

; 11 = MMSYSERR_INVALPARAM

While 1
    Sleep(100)
WEnd

Func start()
;nothing yet
EndFunc

Func stop()
;nothing yet
EndFunc

Func SpecialEvents()
    Exit
EndFunc
Edited by torun

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0