Blitzmax MIDI IN

BlitzMax Forums/BlitzMax Programming/Blitzmax MIDI IN

I have uploaded the whole folder including the port MIDI I am using to:

http://www.nigelibrown.pwp.blueyonder.co.uk/blitz/userlibs/index.htm

If you just want to deal exclusivley with MIDI messages then try opening - reading and then closing with something like this:

Strict

Import "portmidi28aug06/porttime/*.h"
Import "portmidi28aug06/porttime/porttime.c"

Import "portmidi28aug06/pm_common/*.h"
Import "portmidi28aug06/pm_common/portmidi.c"


?Win32

	Import "portmidi28aug06/porttime/ptwinmm.c"

	Import "portmidi28aug06/pm_win/*.h"
	Import "portmidi28aug06/pm_win/pmwin.c"
	Import "portmidi28aug06/pm_win/pmdll.c"
	Import "portmidi28aug06/pm_win/pmwinmm.c"

	Import "sysex.cpp"

Framework		brl.d3d7max2d

?MacOS
?Linux
?

Extern "C"		' sysex.cpp

	Global	OutputDevice:Int
	Global	InputDevice:Int
	Global	LoopbackInputDevice:Int
	Global	LoopbackOutputDevice:Int

	Global	midi_message:Byte[]

	Function 	midi_open:Int()
	Function 	midi_close:Int()
	Function 	midi_test:Byte Ptr()

	Function 	loopback_open:Int()
	Function 	loopback_close:Int()
	Function 	loopback_test:Int()

	Function 	get_midi_in()
	Function 	get_midi_out()

	Function 	sysex_receive_open:Int()
	Function 	sysex_receive_get:Byte Ptr()
	Function 	sysex_receive_close:Int()

	Function 	sysex_send( message:Byte Ptr )
	Function 	sysex_send_receive:Byte Ptr( message:Byte Ptr )

	Function 	sysex_initalise()
	Function 	sysex_set_device:Int( device:Byte Ptr, dir:Int )
	Function 	sysex_get_next_device:String( nxt:Int, dir:Int )
	Function 	sysex_get_number_of_devices:Int()

	Function 	sysex_finalise()

End Extern

	sysex_initalise()
	Delay(5000)

	' List input / output devices
	For Local i:Int=0 To sysex_get_number_of_devices()-1
	
		If sysex_get_next_device(i,True) = ""
		Else
			DebugLog "Output Device [" + i + "] = " + sysex_get_next_device(i,True)
		EndIf
	
		If sysex_get_next_device(i,False) = ""
		Else
			DebugLog "Input Device [" + i + "] = " + sysex_get_next_device(i,False)
		EndIf
		
	Next

	' Change these to correct values for your setup.
	InputDevice = 2
	OutputDevice = 5

    '
    If sysex_get_next_device( InputDevice , False ) = ""
        If Not Confirm( "No compatible MIDI input device selected, Continue?", True )
            Return False
        EndIf
    EndIf

    '
    If sysex_get_next_device( OutputDevice, True ) = ""
        If Not Confirm( "No compatible MIDI output device selected, Continue?", True )
            Return False
        EndIf
    EndIf


	Global bp:Byte Ptr

	midi_open()

	Repeat
	
		bp = midi_test()

		If bp <> Null
			DebugLog "status = " + bp[0]
			DebugLog "data1 = " + bp[1]
			DebugLog "data2 = " + bp[2]
			DebugLog ""
		EndIf
	
	Until KeyDown(KEY_ESCAPE)
	
	midi_close()
	

sysex_finalise()

End