Include a header file required for build on mac 10.4
[supercollider.git] / Help / Control / MIDIOut.html
blob6d0fc1e29795236ff9024051252d7655289e1cc8
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: 9.0px Monaco; min-height: 12.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: 9.0px Monaco}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #c40000}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0010c4}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #007200; min-height: 12.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #007200}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0010c4; min-height: 12.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
21 span.s1 {color: #0010c4}
22 span.s2 {color: #000000}
23 span.s3 {color: #007200}
24 span.Apple-tab-span {white-space:pre}
25 </style>
26 </head>
27 <body>
28 <p class="p1"><b>MIDIOut</b></p>
29 <p class="p2"><br></p>
30 <p class="p3"><b>send midi messages</b></p>
31 <p class="p4"><br></p>
32 <p class="p3">a MIDIOut is bound to a specific MIDIEndPoint as defined by the operating system</p>
33 <p class="p4"><br></p>
34 <p class="p3">list out ports:<span class="Apple-converted-space"> </span></p>
35 <p class="p5"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span></span><span class="s1">MIDIClient</span>.destinations</p>
36 <p class="p4"><br></p>
37 <p class="p3"><span class="Apple-converted-space"> </span><b>*new(port, uid)</b></p>
38 <p class="p3"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span></span>port is the index of the MIDIEndPoint in the MIDIClient.destinations array.</p>
39 <p class="p4"><span class="Apple-converted-space"> </span></p>
40 <p class="p3"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span></span>Mac OSX / Windows: uid is optional; if specified, it should be the uid of that port</p>
41 <p class="p3"><span class="Apple-tab-span"> </span> <span class="Apple-tab-span"> </span>ie. MIDIClient.destinations[port].uid</p>
42 <p class="p3"><span class="Apple-tab-span"> </span> <span class="Apple-tab-span"> </span>If you don't provide a uid, the correct uid will be filled in for you (easier)</p>
43 <p class="p4"><br></p>
44 <p class="p3"><span class="Apple-tab-span"> </span> Linux: using the uid is optional as described below</p>
45 <p class="p4"><br></p>
46 <p class="p4"><b><span class="Apple-tab-span"> </span></b></p>
47 <p class="p3"><span class="Apple-converted-space"> </span><b>*newByName(deviceName,portName)</b></p>
48 <p class="p3"><b><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span></span></b>Searches for the device by name. This is safer then depending on the index which will change</p>
49 <p class="p3"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span></span>if your studio setup changes.</p>
50 <p class="p3"><span class="Apple-tab-span"> </span>list connected out ports with names:<span class="Apple-converted-space"> </span></p>
51 <p class="p5"><span class="Apple-tab-span"> </span> <span class="Apple-tab-span"> </span><span class="s1">MIDIClient</span>.destinations</p>
52 <p class="p2"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span></p>
53 <p class="p3"><span class="Apple-converted-space"> </span><b>*findPort(deviceName,portName)</b></p>
54 <p class="p3"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span></span>searches for a connected MIDIEndPoint by name</p>
55 <p class="p3"><span class="Apple-tab-span"> </span>list connected out ports with names:<span class="Apple-converted-space"> </span></p>
56 <p class="p5"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s1">MIDIClient</span>.destinations</p>
57 <p class="p4"><br></p>
58 <p class="p3"><b>  *connect(port, uid)</b> (Linux only)</p>
59 <p class="p3">  <b>*disconnect(port, uid)</b> (Linux only)</p>
60 <p class="p3"><span class="Apple-tab-span"> </span>OS X does not need to connect. On Linux it is an optional feature (see below).</p>
61 <p class="p4"><br></p>
62 <p class="p3"><span class="Apple-converted-space"> </span><b>latency_( time )</b></p>
63 <p class="p3"><span class="Apple-tab-span"> </span>This sets the latency with which a midi event is sent out. Per default this is set to 0.2, in order to be equal to the Server.latency.<br>
64 NOTE: on Linux there seems to be an ALSA or kernel bug if the latency is larger than 0, for some Linux kernels. If MIDIOut does not seem to work, set the latency to 0.</p>
65 <p class="p4"><br></p>
66 <p class="p3"><span class="Apple-converted-space"> </span><b>noteOn</b> ( chan, note, veloc )</p>
67 <p class="p3"><span class="Apple-converted-space"> </span><b>noteOff</b> ( chan, note, veloc )</p>
68 <p class="p3"><span class="Apple-converted-space"> </span><b>polyTouch</b> ( chan, note, val )</p>
69 <p class="p3"><span class="Apple-converted-space"> </span><b>control</b> ( chan, ctlNum, val )</p>
70 <p class="p3"><span class="Apple-converted-space"> </span><b>program</b> ( chan, num )</p>
71 <p class="p3"><span class="Apple-converted-space"> </span><b>touch</b> ( chan, val )</p>
72 <p class="p3"><span class="Apple-converted-space"> </span><b>bend</b> ( chan, val )</p>
73 <p class="p3"><span class="Apple-converted-space"> </span><b>allNotesOff</b> ( chan )</p>
74 <p class="p3"><span class="Apple-converted-space"> </span><b>smpte</b> ( frames, seconds, minutes, hours, frameRate )</p>
75 <p class="p3"><span class="Apple-converted-space"> </span><b>songPtr</b> ( songPtr )</p>
76 <p class="p3"><span class="Apple-converted-space"> </span><b>songSelect</b> ( song )</p>
77 <p class="p3"><span class="Apple-converted-space"> </span><b>midiClock</b> (<span class="Apple-converted-space">  </span>)</p>
78 <p class="p3"><span class="Apple-converted-space"> </span><b>startClock</b> (<span class="Apple-converted-space">  </span>)</p>
79 <p class="p3"><span class="Apple-converted-space"> </span><b>continueClock</b> (<span class="Apple-converted-space">  </span>)</p>
80 <p class="p3"><span class="Apple-converted-space"> </span><b>stopClock</b> (<span class="Apple-converted-space">  </span>)</p>
81 <p class="p3"><span class="Apple-converted-space"> </span><b>reset</b> (<span class="Apple-converted-space">  </span>)</p>
82 <p class="p3"><span class="Apple-converted-space"> </span><b>sysex</b> ( Int8Array )</p>
83 <p class="p3"><b> connect(uid)</b> (Linux only)</p>
84 <p class="p3"> <b>disconnect(uid)</b> (Linux only)</p>
85 <p class="p4"><br></p>
86 <p class="p3"> private methods:</p>
87 <p class="p3"><span class="Apple-converted-space"> </span><b>send</b> ( outport, uid, len, hiStatus, loStatus, a, b, latency )</p>
88 <p class="p3"><span class="Apple-converted-space"> </span><b>prSysex</b> ( uid, Int8Array )</p>
89 <p class="p3"><b> *connectByUID(port, uid)</b> (Linux only)</p>
90 <p class="p3"> <b>*disconnectByUID(port, uid)</b> (Linux only)</p>
91 <p class="p2"><br></p>
92 <p class="p2"><br></p>
93 <p class="p2"><br></p>
94 <p class="p6">// examples:</p>
95 <p class="p2"><br></p>
96 <p class="p7">MIDIClient<span class="s2">.init;</span></p>
97 <p class="p2"><br></p>
98 <p class="p5">m = <span class="s1">MIDIOut</span>(0);</p>
99 <p class="p5">m.noteOn(16, 60, 60);</p>
100 <p class="p5">m.noteOn(16, 61, 60);</p>
101 <p class="p5">m.noteOff(16, 61, 60);</p>
102 <p class="p5">m.allNotesOff(16);</p>
103 <p class="p2"><br></p>
104 <p class="p2"><br></p>
105 <p class="p6"><span class="s1">MIDIIn</span><span class="s2">.connect; </span>// 1 port midi interface</p>
106 <p class="p5"><span class="s1">MIDIIn</span>.sysex = { <span class="s1">arg</span> uid, packet; [uid,packet].postln };</p>
107 <p class="p5"><span class="s1">MIDIIn</span>.sysrt = { <span class="s1">arg</span> src, chan, val;<span class="Apple-converted-space">  </span>[src, chan, val].postln; };</p>
108 <p class="p5"><span class="s1">MIDIIn</span>.smpte = { <span class="s1">arg</span> src, chan, val;<span class="Apple-converted-space">  </span>[src, chan, val].postln; };</p>
109 <p class="p2"><br></p>
110 <p class="p5">m.sysex(<span class="s1">Int8Array</span>[ 16rf0, 0, 0, 27, 11, 0,16rf7])</p>
111 <p class="p2"><br></p>
112 <p class="p5">m.smpte(24,16)<span class="Apple-converted-space"> </span></p>
113 <p class="p5">m.midiClock<span class="Apple-converted-space"> </span></p>
114 <p class="p5">m.start<span class="Apple-converted-space"> </span></p>
115 <p class="p5">m.continue<span class="Apple-converted-space"> </span></p>
116 <p class="p5">m.stop<span class="Apple-converted-space"> </span></p>
117 <p class="p2"><br></p>
118 <p class="p2"><br></p>
119 <p class="p2"><br></p>
120 <p class="p3"><b>Using patterns for sending midi events</b></p>
121 <p class="p2"><br></p>
122 <p class="p7">MIDIClient<span class="s2">.init;</span></p>
123 <p class="p5">m = <span class="s1">MIDIOut</span>(0);</p>
124 <p class="p2"><br></p>
125 <p class="p5">a = <span class="s1">Pbind</span>(<span class="s3">\degree</span>, <span class="s1">Prand</span>([1, 2, 3, [0, 5]], <span class="s1">inf</span>), <span class="s3">\bend</span>, <span class="s1">Pwhite</span>(0, 76, <span class="s1">inf</span>));</p>
126 <p class="p2"><br></p>
127 <p class="p2"><br></p>
128 <p class="p6">// chain a midi event into the pattern and play it (see <a href="../Streams-Patterns-Events/Patterns/Pchain.html"><span class="s1">Pchain</span></a>)</p>
129 <p class="p2"><br></p>
130 <p class="p5">(a &lt;&gt; (type: <span class="s3">\midi</span>, midiout: m)).play;</p>
131 <p class="p2"><br></p>
132 <p class="p2"><br></p>
133 <p class="p3">The following keys are supported by midi event:</p>
134 <p class="p8"><br></p>
135 <p class="p9">\noteOn</p>
136 <p class="p9">\noteOff</p>
137 <p class="p9">\polyTouch</p>
138 <p class="p9">\control</p>
139 <p class="p9">\program</p>
140 <p class="p9">\touch</p>
141 <p class="p9">\bend</p>
142 <p class="p9">\allNotesOff</p>
143 <p class="p9">\smpt</p>
144 <p class="p9">\songPtr</p>
145 <p class="p9">\sysex</p>
146 <p class="p2"><br></p>
147 <p class="p2"><br></p>
148 <p class="p2"><br></p>
149 <p class="p4"><br></p>
150 <p class="p3"><b>Linux specific: Connecting and disconnecting ports.</b></p>
151 <p class="p4"><br></p>
152 <p class="p3">On Linux, a MIDIOut can be created without setting the destination:</p>
153 <p class="p2"><br></p>
154 <p class="p5">m = <span class="s1">MIDIOut</span>(0);</p>
155 <p class="p4"><br></p>
156 <p class="p3">in this case each message will be sent to all ports connected to SuperCollider's first MIDI output.<span class="Apple-converted-space"> </span></p>
157 <p class="p4"><br></p>
158 <p class="p3">A connection can be made through:</p>
159 <p class="p2"><br></p>
160 <p class="p5">m.connect( 2 );</p>
161 <p class="p4"><br></p>
162 <p class="p3">Note that by connecting in this way, you can connect more than one destination to the MIDI output.</p>
163 <p class="p3">You can also use other tools to connect to a MIDIOut port of SC, e.g. through aconnect or QJackCtl (on the ALSA tab).</p>
164 <p class="p4"><br></p>
165 <p class="p3">If you set the uid in MIDIOut, a direct connection is established and data will only be sent to that MIDI input port, and not to any other connections made to SC's MIDI output port (through the connect message or external tools).</p>
166 <p class="p4"><br></p>
167 <p class="p4"><br></p>
168 <p class="p3"><b>OS X specific: Sending MIDI to other applications</b></p>
169 <p class="p2"><br></p>
170 <p class="p3">Open the Audio MIDI Setup application.<span class="Apple-converted-space">  </span>Double-click on IAC Driver and check "device is online". <span class="Apple-converted-space"> </span></p>
171 <p class="p10"><br></p>
172 <p class="p3">reinitialize:</p>
173 <p class="p10"><br></p>
174 <p class="p5"><span class="s1">MIDIClient</span>.init(numIns,numOuts)</p>
175 <p class="p2"><br></p>
176 <p class="p3">The IAC Bus will now appear in MIDIClient.destinations.<span class="Apple-converted-space">  </span>It will appear first, which means that any code that you have written that addresses the first physical bus as 0 will now have to be changed.</p>
177 <p class="p4"><br></p>
178 <p class="p3">For this reason it is always safer to find the port by name :</p>
179 <p class="p11"><span class="s2"><span class="Apple-tab-span"> </span></span><span class="s1">MIDIOut</span><span class="s2">.newByName(</span>"RemoteSL IN"<span class="s2">,</span>"Port 1"<span class="s2">)</span></p>
180 <p class="p4"><span class="Apple-tab-span"> </span></p>
181 <p class="p3">The IAC Bus will now also appear to other applications.</p>
182 <p class="p4"><br></p>
183 <p class="p2"><br></p>
184 <p class="p3">MIDIMonitor (freeware) can be very useful for troubleshooting:</p>
185 <p class="p2"><br></p>
186 <p class="p5">http://www.snoize.com/MIDIMonitor/</p>
187 <p class="p2"><br></p>
188 <p class="p4"><br></p>
189 <p class="p4"><br></p>
190 </body>
191 </html>