binbinhfr Posted October 30, 2021 Posted October 30, 2021 Hi, I am trying to receive MIDI messages from a MIDI device. I can open it and send out MIDI messages, but I have more problems to receive MIDI messages. It is based on events, and I have problem interfacing with the window API. Basically I have 2 functions : midiInOpen (that opens for reception, with a reference to a callback function that I must provide (using the CALLBACK_FUNCTION flag) https://docs.microsoft.com/en-us/previous-versions/ms711610(v=vs.85) and the callback function itself, midiInProc https://docs.microsoft.com/en-us/previous-versions/ms711612(v=vs.85) (I wonder what is this function infact, because I have to write my own... is it a template ?) So how to write my own MidInProc, and how to declare it properly in the midiInOpen call ??? Here is what I wrote but it is not working, even though the midiInOpen returns no error (so the device is opened, but the callback does not give any result when MIDI data is coming).... So I wonder if it's the right way to use DllCallbackRegister and DLLCallbackGetPtr, and if I understood the params declaration... Especially in my MidiWinProc2 definition, where finally I do not give any type/size to these params... But I suppose it is the role of DllCallbackRegister ? global $cbHandle = DllCallbackRegister("MidiWinProc2", "int", "int;uint;dword_ptr;dword_ptr;dword_ptr") $iRet = _MidiIn_Open($nMidiInDevice, DllCallbackGetPtr($cbHandle), 0, BitOR($CALLBACK_FUNCTION, $MIDI_IO_STATUS)) Func MidiWinProc2($hMidiIn,$wMsg,$dwInstance,$dwParam1,$dwParam2) debug("midi in 2") EndFunc Func _MidiIn_Open($uDeviceID, $dwCallback, $dwCallbackInstance, $dwFlags) Local $aResult = DllCall($MIDI_WinMM_DLL,"int","midiInOpen","int*", 0,"uint_ptr",$uDeviceID,"dword_ptr",$dwCallback,"dword_ptr",$dwCallbackInstance,"dword",$dwFlags) If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False) If $aResult[0] = $MMSYSERR_NOERROR Then Return 1 ElseIf $aResult[0] = $MMSYSERR_ALLOCATED Then Return SetError(1,1,0) ElseIf $aResult[0] = $MMSYSERR_BADDEVICEID Then Return SetError(2,2,0) ElseIf $aResult[0] = $MMSYSERR_INVALFLAG Then Return SetError(3,3,0) ElseIf $aResult[0] = $MMSYSERR_INVALPARAM Then Return SetError(4,4,0) ElseIf $aResult[0] = $MMSYSERR_NOMEM Then Return SetError(5,5,0) Else Return SetError(6,6,0) EndIf EndFunc ; Thanks for your help
Danyfirex Posted November 5, 2021 Posted November 5, 2021 Hello It looks right. just change MidiWinProc2 return value to "none" Saludos Danysys.com AutoIt... Reveal hidden contents UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now