cmake build system: visiblity support for clang
[supercollider.git] / Help / Control / MIDIResponder.html
blobe0da2ce3636d1811896cf4990e7c59148fefd62b
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="824.48">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 29.0px; text-indent: -29.0px; font: 12.0px Helvetica}
16 p.p7 {margin: 0.0px 0.0px 0.0px 29.0px; text-indent: -29.0px; font: 12.0px Helvetica; min-height: 14.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #a8220e}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000000}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0013bb}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #84331b; min-height: 12.0px}
23 span.s1 {color: #0013bb}
24 span.s2 {color: #000000}
25 span.Apple-tab-span {white-space:pre}
26 </style>
27 </head>
28 <body>
29 <p class="p1"><b>MIDIResponder</b></p>
30 <p class="p2"><br></p>
31 <p class="p3"><b>Register multiple functions to be evaluated when MIDI events occur.</b></p>
32 <p class="p4"><br></p>
33 <p class="p3">MIDIResponder is an abstract class. Its subclasses allow functions to be registered to respond to midi events.</p>
34 <p class="p4"><br></p>
35 <p class="p3">Read the general help file here and then see the individual help files.</p>
36 <p class="p4"><br></p>
37 <p class="p3"><b>CCResponder<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Respond to control messages</p>
38 <p class="p3"><b>NoteOnResponder<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Respond to note-on messages</p>
39 <p class="p3"><b>NoteOffResponder<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Respond to note-off messages</p>
40 <p class="p3"><b>BendResponder<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Respond to pitch bend messages</p>
41 <p class="p3"><b>TouchResponder<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Respond to aftertouch messages</p>
42 <p class="p4"><br></p>
43 <p class="p4"><br></p>
44 <p class="p5"><b>Creation and initialization:</b></p>
45 <p class="p4"><br></p>
46 <p class="p3"><b>CCResponder(function, src, chan, num, value, install = true,swallowEvent = false)</b></p>
47 <p class="p3"><b>NoteOnResponder(function, src, chan, num, veloc, install = true,swallowEvent = false)</b></p>
48 <p class="p3"><b>NoteOffResponder(function, src, chan, num, veloc, install = true,swallowEvent = false)</b></p>
49 <p class="p3"><b>BendResponder(function, src, chan, value, install = true,swallowEvent = false)</b></p>
50 <p class="p3"><b>TouchResponder(function, src, chan, value, install = true,swallowEvent = false)</b></p>
51 <p class="p4"><br></p>
52 <p class="p6"><b>function</b>: The function to execute when the incoming MIDI event matches the responder. The function takes the arguments src, chan, A, B (or for Bend and Touch, src, chan, value).</p>
53 <p class="p6"><b>src</b>: If a number is given, the responder will fire only for messages coming in from this port. The number may be the system UID (obtained from MIDIClient.sources[index].uid) or the index itself. If nil, the responder will match any port.</p>
54 <p class="p6"><b>chan</b>: The MIDI channel(s) to match.</p>
55 <p class="p6"><b>num</b>: The control or note number(s) to match.</p>
56 <p class="p6"><b>value</b>: The value(s) to match.</p>
57 <p class="p6"><b>veloc</b>: The velocities to match.</p>
58 <p class="p6"><b>install</b>: If true, install the responder automatically so it is active and ready to respond.<span class="Apple-converted-space"> </span></p>
59 <p class="p6"><span class="Apple-tab-span"> </span>If false, then it will be inactive.</p>
60 <p class="p6"><b>swallowEvent</b>: if true, then if the midi event is matched, cease testing any further responders.</p>
61 <p class="p6"><span class="Apple-tab-span"> </span>eg. if a CCResponder matches port, chan and num, and swallowEvent is set to true,</p>
62 <p class="p6"><span class="Apple-tab-span"> </span>then no further CCResponders will be offered the chance to respond to the event.<span class="Apple-converted-space">  </span>The event is<span class="Apple-converted-space"> </span></p>
63 <p class="p6"><span class="Apple-tab-span"> </span>"swallowed".</p>
64 <p class="p6"><span class="Apple-tab-span"> </span>by default this is false.</p>
65 <p class="p7"><span class="Apple-tab-span"> </span></p>
66 <p class="p3">Any of the matching values may be one of the following:</p>
67 <p class="p4"><br></p>
68 <p class="p3"><b>Nil</b>:<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Match anything.<span class="Apple-converted-space">  </span>eg. If chan is nil, then respond to any midi channel.</p>
69 <p class="p3"><b>Integer</b>:<span class="Apple-tab-span"> </span>Match only this specific number.</p>
70 <p class="p3"><b>Array</b>:<span class="Apple-tab-span"> </span>Match any item in the array. Any kind of Collection will work here.</p>
71 <p class="p3"><b>Function</b>:<span class="Apple-tab-span"> </span>Evaluate the function with the incoming value as the argument. The function should return true or false.</p>
72 <p class="p4"><br></p>
73 <p class="p3">For instance, the following example would respond to note on messages from any port, channels 2 and 7 only, even numbered note numbers only, and only velocity values greater than 50.<span class="Apple-converted-space"> </span></p>
74 <p class="p4"><br></p>
75 <p class="p8"><span class="s1">NoteOnResponder</span>({ <span class="s1">|src, chan, num, vel|</span> [src, chan, num, vel].postln },<span class="Apple-converted-space"> </span></p>
76 <p class="p9"><span class="s2"><span class="Apple-tab-span"> </span></span><span class="s1">nil</span><span class="s2">, </span>// any port</p>
77 <p class="p9"><span class="s2"><span class="Apple-tab-span"> </span>[2, 7], </span>// midi channels 2 or 7 only</p>
78 <p class="p9"><span class="s2"><span class="Apple-tab-span"> </span>(0, 2..126),<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// this is an array of even numbers.<span class="Apple-converted-space">  </span>could also be specified as { |num| num.even } or _.even</p>
79 <p class="p9"><span class="s2"><span class="Apple-tab-span"> </span>{ </span><span class="s1">|vel|</span><span class="s2"> vel &gt; 50 }); </span>// velocities greater than 50</p>
80 <p class="p4"><br></p>
81 <p class="p3">MIDIResponders automatically initialize the MIDIClient with 1 standard device.<span class="Apple-converted-space">  </span>This means the first time you install any MIDIResponder, it will make sure that MIDI has been initialized.<span class="Apple-converted-space">  </span>If you have more devices or a specific setup, simply initialize the MIDIClient yourself before using any MIDIResponders.</p>
82 <p class="p4"><br></p>
83 <p class="p10"><b>learn</b></p>
84 <p class="p4"><br></p>
85 <p class="p3">CCResponder, NoteOnResponder, NoteOffResponder, BendResponder and TouchResponder can be set to learn mode and will wait for the next event.</p>
86 <p class="p4"><br></p>
87 <p class="p4"><br></p>
88 <p class="p4"><br></p>
89 <p class="p5"><b>Removal:</b></p>
90 <p class="p4"><br></p>
91 <p class="p3">Just call .remove on the responder.</p>
92 <p class="p4"><br></p>
93 <p class="p9"><span class="s2">c = </span><span class="s1">CCResponder</span><span class="s2">({ ... }, num: 1);<span class="Apple-tab-span"> </span></span>// respond to any modwheel</p>
94 <p class="p11"><br></p>
95 <p class="p9"><span class="s2">c.remove;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// stop this responder</p>
96 <p class="p11"><br></p>
97 <p class="p3">Or remove all of a specific class:</p>
98 <p class="p11"><br></p>
99 <p class="p12">CCResponder<span class="s2">.removeAll</span></p>
100 <p class="p12">NoteOnResponder<span class="s2">.removeAll</span></p>
101 <p class="p12">NoteOffResponder<span class="s2">.removeAll</span></p>
102 <p class="p12">BendResponder<span class="s2">.removeAll</span></p>
103 <p class="p12">TouchResponder<span class="s2">.removeAll</span></p>
104 <p class="p11"><br></p>
105 <p class="p3">or remove all midi responders in all classes:</p>
106 <p class="p11"><br></p>
107 <p class="p12">MIDIResponder<span class="s2">.removeAll</span></p>
108 <p class="p11"><br></p>
109 <p class="p13"><br></p>
110 <p class="p13"><br></p>
111 <p class="p13"><br></p>
112 </body>
113 </html>