Clamps Packages
MIDI Input
Receiving and handling MIDI Input
After the Ports have been opened, MIDI input handling is started using the function start-midi-receive, which gets called automatically on startup using the clamps function. MIDI input handling can be suspended using the stop-midi-receive function. Note that this will not close the MIDI ports, so connections to external devices or programs will be persistent. A later call to start-midi-receive will continue to process MIDI input.
Handling MIDI input in Clamps is done in 3 different stages:
- All note and cc input is captured in the special variables *midi-cc-state* and *midi-note-state*. Both contain a 2-dimensional array of 16x128 ref-objects which capture the last received values of the 128 controller numbers or note numbers of all 16 MIDI channels. Inspect this value to see the current state of the MIDI input of Clamps.
- In addition two other special variables, *midi-cc-fns* and *midi-note-fns* contain 16x128 lists, intially empty. When receiving MIDI cc or MIDI note input, Clamps will address these arrays and call all functions stored in the list of the corresponding channel and CC number or keynum with the received controller value or note velocity as arguments.
- At last, the #'handle-midi-in method of all midi controller instances registered with the function add-midi-controller will get called.