Constrained MIDI events
<< Click to Display Table of Contents >> Navigation: Callbacks > MIDI Events > Constrained MIDI events |
The Note events (Note, NoteOn, NoteOff) and the ControlChange event can optionally include a constraint that specifies either a range or an explicit sequence of numbers for which the callback is triggered. For example:
On NoteEvent (m : NoteMessage) Matching [C3..C4] From <MidiIn block name>
// This event is only called if you play a note with
// a MIDI note number that is in the range 60 to 72
End
On ControlChangeEvent (c : ControlChangeMessage) Matching 1,7,14 From <MidiIn block name>
// This event is only called for controller numbers
// 1, 7 or 14
End
When you used constrained events, you can have multiple events of the same kind as long as their ranges have no overlaps. The main purpose of this mechanism is to allow you to specify callbacks for specific purposes without having to handle all events in your script. For example, you might create a callback to handle key switches where the bottom octave of your keyboard is used for controlling some effects while notes in other octaves are handled normally.
If you create a callback with no constraints, then any subsequent callbacks with constraints will cause a compilation error because your non-constrained callback is handling all possible values.
On the other hand, if you create some callbacks with constraints and add a non-constrained callback afterwards, then that last callback will apply just to values that have not been specified in previously defined constrained callbacks.