oneShot: free the responder before running user func (avoid error)
[supercollider.git] / HelpSource / Classes / ProgramChangeResponder.schelp
blob93b6578794c8f033e77caffc71fe0b61e8c0b444
1 class:: ProgramChangeResponder
2 summary:: allow functions to be registered to respond to MIDI program change events
3 related:: Classes/MIDIFunc, Classes/MIDIdef, Classes/MIDIResponder, Classes/CCResponder
4 categories:: MIDI
6 Description::
7 note:: As of SC 3.5 link::Classes/MIDIFunc:: and link::Classes/MIDIdef:: are the recommended way of registering for incoming MIDI messages. They are faster, safer, and have more logical argument order than the old MIDI responder classes. The older class MIDIResponder, and its subclasses NoteOnResponder, NoteOffResponder, BendResponder, TouchResponder, CCResponder, and ProgramChangeResponder are maintained for legacy code only.:: 
8 ClassMethods::
10 method::new
12 argument::function
13 A link::Classes/Function:: to be evaluated. Arguments passed to the function are: src, chan, value.
15 argument::src
16 The src number may be the system UID (obtained from code:: MIDIClient.sources[index].uid ::) or the index of the source in the code:: MIDIClient.sources :: array. nil matches all.
18 argument::chan
19 An link::Classes/Integer:: between 0 and 15 that selects which MIDI channel to match. nil matches all. May also be a link::Classes/Function:: which will be evaluated to determine the match. eg: { |val| val < 2 }
21 argument::num
22 An link::Classes/Integer:: between 0 and 127 that selects which program change number to match. nil matches all. May also be a link::Classes/Function:: which will be evaluated to determine the match. eg: { |val| val >= 4 }
24 argument::value
25 An link::Classes/Integer:: between 0 and 127 to filter values. nil matches all. May also be a link::Classes/Function:: which will be evaluated to determine the match. eg: { |val| val < 50 }
27 argument::install
28 If true, install the responder automatically so it is active and ready to respond. If false, then it will be inactive.
30 Examples::
32 code::
34         c = ProgramChangeResponder({ |src,chan,val|
35                 [src,chan,val].postln;
36                 },
37                 nil, // any source
38                 nil, // any channel
39                 nil // any value
40         )
43 c.remove
46 code::
48         c = ProgramChangeResponder({ |src,chan,val|
49                 [src,chan,val].postln;
50                 },
51                 nil, // any source
52                 nil, // any channel
53                 (50..60) // within this value range
54         )
57 c.remove