Sending and receiving MIDI data
by Richard Russell, December 2010
MIDI (Musical Instrument Digital Interface) is a standard means of communicating with a digital musical instrument, whether an input device like a keyboard or an output device like a synthesiser.
To output data to a MIDI device you can adapt the example program MIDITEST listed here. Note that the routine PROCsblast opens the default MIDI output device; if you have more than one MIDI output device you may need to change the parameter -1 (signifying MIDI_MAPPER) to the appropriate device number.
To input data from a MIDI device you can adapt the example program MIDIIN which can be downloaded from here. This program 'loops' the MIDI input to the MIDI output in software, but you should be able to see how to adapt it to utilise the received data for other purposes. The program opens MIDI input device 0 so if necessary change the device number in the midiInOpen call.