2 summary:: MIDI response reference definition
3 categories:: External Control>MIDI
4 related:: Guides/MIDI, Classes/MIDIdef
7 MIDIdef provides a global reference to the functionality of its superclass link::Classes/MIDIFunc::. Essentially it stores itself at a key within a global dictionary, allowing replacement at any time. Most methods are inherited from its superclass.
9 note:: Use of the older classes MIDIResponder, CCResponder, NoteOnResponder, NoteOffResponder, BendResponder, TouchResponder, and ProgramChangeResponder can be unsafe, since responders in user and class code can override each other unintentionally. MIDIdef and link::Classes/MIDIFunc:: are faster, safer, and have more logical argument order. Thus they are the recommended way of registering for incoming MIDI messages as of SC 3.5.::
16 Get the global dictionary of all MIDIdefs.
18 returns:: An link::Classes/IdentityDictionary::.
21 Create a new, enabled MIDIdef. If a MIDIdef already exists at this key, its parameters will be replaced with the ones provided (args for which nil is passed will use the old values). Normally one would use one of the message type specific convenience methods below, rather than use this method directly.
24 The key at which to store this OSCdef in the global collection. Generally this will be a link::Classes/Symbol::.
27 A link::Classes/Function:: or similar object which will respond to the incoming message. When evaluated for noteOn, noteOff, control, and polytouch messages it will be passed the arguments val, num, chan, and src, corresponding to the message value (e.g. velocity, control value, etc.), message number (e.g. note number), MIDI channel, and MIDI source uid. For touch, programme change and bend messages it will be passed only val, chan, and src.
30 An link::Classes/Integer:: indicating the MIDI message number (note number, control number, or programme number) for this MIDIdef. This can be an array. If nil, the MIDIdef will respond to messages of all possible message numbers.
33 An link::Classes/Integer:: indicating the MIDI channel number for this MIDIdef. This can be an array. If nil, the MIDIdef will respond to messages received on all channels.
36 A link::Classes/Symbol:: indicating which kind of MIDI message this MIDIdef should respond to. One of code::\noteOn::, code::\noteOff::, code::\control::, code::\touch::, code::\polytouch::, code::\bend::, or code::program::.
39 An link::Classes/Integer:: corresponding to the uid of the MIDI input. (See link::Classes/MIDIClient::.) If nil, the MIDIdef will respond to messages received from all sources.
41 argument:: argTemplate
42 An optional link::Classes/Integer:: or link::Classes/Function:: (or object which responds to the method link::Overviews/Methods#matchItem::) used to match the value of an incoming MIDI message. (e.g. velocity, control value, program number, etc.). If a Function, it will be evaluated with the message value as an argument, and should return a link::Classes/Boolean:: indicating whether the message matches and this MIDIdef should respond.
45 An optional instance of an appropriate subclass of link::Classes/AbstractDispatcher::. This can be used to allow for customised dispatching. Normally this should not be needed.
47 returns:: An instance of MIDIdef.
50 A convenience method to create a new MIDIdef which responds to MIDI control messages. See link::#*new:: for argument descriptions.
52 returns:: An instance of MIDIdef which responds to MIDI control messages.
55 A convenience method to create a new MIDIdef which responds to MIDI note on messages. See link::#*new:: for argument descriptions.
57 returns:: An instance of MIDIdef which responds to MIDI note on messages.
60 A convenience method to create a new MIDIdef which responds to MIDI note off messages. See link::#*new:: for argument descriptions.
62 returns:: An instance of MIDIdef which responds to MIDI note off messages.
65 A convenience method to create a new MIDIdef which responds to MIDI polytouch messages. See link::#*new:: for argument descriptions.
67 returns:: An instance of MIDIdef which responds to MIDI polytouch messages.
70 A convenience method to create a new MIDIdef which responds to MIDI touch messages. See link::#*new:: for argument descriptions.
72 returns:: An instance of MIDIdef which responds to MIDI touch messages.
75 A convenience method to create a new MIDIdef which responds to MIDI bend messages. See link::#*new:: for argument descriptions.
77 returns:: An instance of MIDIdef which responds to MIDI bend messages.
80 A convenience method to create a new MIDIdef which responds to MIDI program change messages. See link::#*new:: for argument descriptions.
82 returns:: An instance of MIDIdef which responds to MIDI program change messages.
85 Clears and deactivates all MIDIdefs from the global collection.
88 private:: addToAll, printOn
91 Get this MIDIdef's key.
93 returns:: Usually a link::Classes/Symbol::.
96 Clears this MIDIdef from the global collection and deactivates it.
103 MIDIdef.cc(\test1, {arg ...args; args.postln}, 1); // match cc 1
104 MIDIdef.cc(\test2, {arg ...args; args.postln}, 1, 1); // match cc1, chan 1
105 MIDIdef.cc(\test3, {arg ...args; args.postln}, (1..10)); // match cc 1-10
106 MIDIdef.noteOn(\test4, {arg ...args; args.postln}); // match any noteOn
108 MIDIIn.doNoteOnAction(1, 1, 64, 64); // spoof a note on
109 MIDIIn.doControlAction(1, 1, 1, 64); // spoof a cc
110 MIDIIn.doControlAction(1, 1, 9, 64);
111 MIDIIn.doControlAction(1, 10, 1, 64);
113 MIDIdef(\test1).free; // free one def
114 MIDIdef.freeAll; // free all registered MIDIdefs