Been writing some software with PureBasic that deals with realtime MIDI commands. Everything is working good using the Callback method and all, read many examples over here and I got my thing running smoothly.
Now, I realized that I have to deal with system exclusive (sysex) as well and I can't figure out how to implement this in PureBasic. I've tried to find examples and blurbs of source code but to no avail.
Here's what I have as a test program, it almost works but I really don't know how to read the Sysex data once the buffer is filed up.
Code: Select all
Global MidiHeader.MIDIHDR
Procedure MIDICallBack0(hMi.l, wMsg.l, dummy.l , Data1.l, Data2.l)
Select wMsg
Case #MIM_DATA
Debug "Normal MIDI Msg"
Case #MIM_LONGDATA
Debug MidiHeader\dwBytesRecorded
EndSelect
EndProcedure
*SysexBuffer = AllocateMemory(16384)
hMiP0.l = 0
MIDIHeader\dwFlags = 0
MidiHeader\dwBufferLength = 16384
MidiHeader\lpData = *SysexBuffer
midiInOpen_(@hMiP0, 1, @MIDICallBack0(), 0, #CALLBACK_FUNCTION)
midiInPrepareHeader_(hMiP0, @MidiHeader, SizeOf(MidiHeader))
midiInAddBuffer_(hMiP0, @MidiHeader, SizeOf(MidiHeader))
midiInStart_(hMiP0)
OpenWindow(0, 10, 10, 200, 200, "MIDI Test")
Repeat
Event = WaitWindowEvent(10)
Until Event = #PB_Event_CloseWindow
;midiInStop_(hMiP0)
midiInUnprepareHeader_(hMiP0, @MidiHeader, SizeOf(MidiHeader))
midiInReset_(hMiP0)
midiInClose_(hMiP0)
Cheers,
-Khorus