Include a header file required for build on mac 10.4
[supercollider.git] / Help / Libraries / JITLib / tutorials / jitlib_basic_concepts_03.html
blob3745dcdbf84ffc9cc3d18665b996cc36c178999b
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="949.43">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.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; min-height: 14.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0021e7}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #862a1b}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #862a1b; min-height: 12.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
19 span.s1 {font: 36.0px Georgia}
20 span.s2 {color: #002df4}
21 span.s3 {color: #000000}
22 span.s4 {text-decoration: underline}
23 span.s5 {color: #0034af}
24 span.s6 {color: #001bb9}
25 span.s7 {color: #862a1b}
26 span.s8 {font: 12.0px Helvetica; color: #000000}
27 span.s9 {font: 9.0px Monaco}
28 span.s10 {font: 9.0px Monaco; color: #862a1b}
29 span.s11 {font: 12.0px Helvetica}
30 span.s12 {color: #4f6823}
31 span.s13 {color: #003ef4}
32 span.Apple-tab-span {white-space:pre}
33 </style>
34 </head>
35 <body>
36 <p class="p1"><b>proxyspace - basic concepts<span class="Apple-converted-space">  <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span></b><span class="s1"><b>3</b></span></p>
37 <p class="p2"><br></p>
38 <p class="p3"><br></p>
39 <p class="p3"><br></p>
40 <p class="p4">internal structure of the node proxy, node order and the parameter context</p>
41 <p class="p2"><br></p>
42 <p class="p4">a) slots</p>
43 <p class="p4">b) fadeTime</p>
44 <p class="p4">b) play/stop, send/release, pause/resume, clear</p>
45 <p class="p4">c) the parameter context</p>
46 <p class="p3"><br></p>
47 <p class="p3"><br></p>
48 <p class="p4">A NodeProxy has two internal contexts in which the objects are inserted:</p>
49 <p class="p4">The group, which is on the server, and the nodeMap, which is a client side</p>
50 <p class="p4">parameter context. As the group can contain an order of synths, there is</p>
51 <p class="p4">a client side representation, in which the source objects are stored (see <a href="../../../Collections/Order.html"><span class="s2">Order</span></a>).</p>
52 <p class="p2"><br></p>
53 <p class="p2"><br></p>
54 <p class="p5"><span class="s3">previous: <a href="jitlib_basic_concepts_02.html"><span class="s4">jitlib_basic_concepts_02</span></a> <span class="Apple-tab-span"> </span>next: <a href="jitlib_basic_concepts_04.html"><span class="s4">jitlib_basic_concepts_04</span></a><span class="Apple-converted-space"> </span></span></p>
55 <p class="p3"><br></p>
56 <p class="p3"><br></p>
57 <p class="p2"><br></p>
58 <p class="p6">// make new space</p>
59 <p class="p7">p = <span class="s5">ProxySpace</span>.push(s.boot);</p>
60 <p class="p6"><span class="s3">~z.play; ~y.ar; </span>// explicitly initialize proxies</p>
61 <p class="p2"><br></p>
62 <p class="p2"><br></p>
63 <p class="p2"><br></p>
64 <p class="p4"><b>a) NodeProxy slots:</b></p>
65 <p class="p2"><br></p>
66 <p class="p4">One node proxy can hold several objects in an execution order. The index can be any positive integer.</p>
67 <p class="p8"><br></p>
68 <p class="p9">// the initial slot (0) is used when assigning directly.</p>
69 <p class="p9">// ~y is still unused, we will add it later.</p>
70 <p class="p2"><br></p>
71 <p class="p7">~z = (~y * pi).sin * 0.1 * { <span class="s6">LFSaw</span>.kr(<span class="s6">LFNoise1</span>.kr(0.1 ! 3).sum * -18).max(0.2) };</p>
72 <p class="p2"><br></p>
73 <p class="p9">// other slot numbers are accessed by positive integers:</p>
74 <p class="p2"><br></p>
75 <p class="p7">~y[1] = { <span class="s6">Saw</span>.ar([400, 401.3], 0.4) };</p>
76 <p class="p7">~y[0] = { <span class="s6">Saw</span>.ar([300, 301], 0.4) };<span class="Apple-converted-space"> </span></p>
77 <p class="p2"><br></p>
78 <p class="p9">// to remove one of them, nil is used:</p>
79 <p class="p2"><br></p>
80 <p class="p7">~y[0] = <span class="s6">nil</span>;</p>
81 <p class="p2"><br></p>
82 <p class="p9">// what is to be found at index 1?</p>
83 <p class="p9"><span class="s3">~y.objects[1] </span>// a playing interface</p>
84 <p class="p9"><span class="s3">~y.objects[1].source.postcs </span>// the function that was put in.</p>
85 <p class="p9"><span class="s3">~y.objects.postcs <span class="Apple-tab-span"> </span></span>// this returns objects in the slots.</p>
86 <p class="p9"><span class="s3">~y.source.postcs<span class="Apple-tab-span"> </span></span>// this returns the function in slot 0 only.</p>
87 <p class="p2"><br></p>
88 <p class="p8"><br></p>
89 <p class="p4">multiple assignment</p>
90 <p class="p8"><br></p>
91 <p class="p6">// the function is assigned to th slots from 1 to 4<span class="Apple-converted-space"> </span></p>
92 <p class="p7">~z[1..4] = { <span class="s5">SinOsc</span>.ar(exprand(300, 600), 0, <span class="s5">LFTri</span>.kr({exprand(1, 3)} ! 3).sum.max(0)) * 0.1 };</p>
93 <p class="p2"><br></p>
94 <p class="p2"><br></p>
95 <p class="p6">// the function is assigned to the slots 1, 2 and 3 (subsequent)</p>
96 <p class="p7">~z[1..] = [ {<span class="s5">SinOsc</span>.ar(440) * 0.1 }, { <span class="s5">SinOsc</span>.ar(870) * 0.08 }, { <span class="s5">SinOsc</span>.ar(770) * 0.04 }];</p>
97 <p class="p2"><br></p>
98 <p class="p6">// if no slot is given, all other slots are emptied</p>
99 <p class="p7">~z = { <span class="s5">OnePole</span>.ar(<span class="s5">Saw</span>.ar([400, 401.3], 0.3), 0.95) };</p>
100 <p class="p2"><br></p>
101 <p class="p7">~z.end;</p>
102 <p class="p7">~y.end;</p>
103 <p class="p3"><br></p>
104 <p class="p3"><br></p>
105 <p class="p3"><br></p>
106 <p class="p4"><b>b) fade time:</b></p>
107 <p class="p2"><br></p>
108 <p class="p6">// setting the fadeTime will allow cross fades.</p>
109 <p class="p6">// in case of an audio rate proxy the fade is pseudo-gaussian</p>
110 <p class="p6">// in case of a control rate proxy it is linear.</p>
111 <p class="p2"><br></p>
112 <p class="p7">~z.play;</p>
113 <p class="p2"><br></p>
114 <p class="p7">~z.fadeTime = 5.0; <span class="s7">// 5 seconds</span></p>
115 <p class="p7">~z = { max(<span class="s5">SinOsc</span>.ar([300, 301]), <span class="s5">Saw</span>.ar([304, 304.3])) * 0.1 };</p>
116 <p class="p7">~z = { max(<span class="s5">SinOsc</span>.ar(<span class="s5">ExpRand</span>(300, 600)), <span class="s5">Saw</span>.ar([304, 304.3])) * 0.1<span class="Apple-converted-space">  </span>};</p>
117 <p class="p2"><br></p>
118 <p class="p6">// the fadeTime can be set effectively at any time</p>
119 <p class="p7">~z.fadeTime = 0.2;</p>
120 <p class="p7">~z = { max(<span class="s5">SinOsc</span>.ar(<span class="s5">ExpRand</span>(3, 160)), <span class="s5">Saw</span>.ar([304, 304.3])) * 0.1 };</p>
121 <p class="p2"><br></p>
122 <p class="p2"><br></p>
123 <p class="p3"><br></p>
124 <p class="p4">note that the fadeTime is also used for the operations xset and xmap.(see below)</p>
125 <p class="p2"><br></p>
126 <p class="p2"><br></p>
127 <p class="p3"><br></p>
128 <p class="p4"><b>c) play/stop, send/free, pause/resume</b></p>
129 <p class="p3"><br></p>
130 <p class="p4">there are a couple of messages a NodeProxy understands that are related to play, stop etc.</p>
131 <p class="p4">Here is what they do.</p>
132 <p class="p3"><br></p>
133 <p class="p4"><b>play/stop</b></p>
134 <p class="p3"><b><span class="Apple-tab-span"> </span></b></p>
135 <p class="p4"><span class="Apple-tab-span"> </span>this pair of messages is related to the monitoring function of the proxy.</p>
136 <p class="p4"><span class="Apple-tab-span"> </span>play starts monitoring, stop ends the monitoring.</p>
137 <p class="p4"><span class="Apple-tab-span"> </span><i>if the proxy group is playing</i> (this can be tested with .isPlaying), play will not</p>
138 <p class="p4"><span class="Apple-tab-span"> </span>affect the proxie's internal behaviour in any way. Only if it is not playing (e.g because</p>
139 <p class="p4"><span class="Apple-tab-span"> </span>one has freed the group by cmd-period) it starts the synths/objects in the proxy.</p>
140 <p class="p4"><span class="Apple-tab-span"> </span>Stop never affects the internal state of the proxy.</p>
141 <p class="p3"><span class="Apple-tab-span"> </span></p>
142 <p class="p6"><span class="s8"><span class="Apple-tab-span"> </span></span>// first hit cmd-period.</p>
143 <p class="p7"><span class="Apple-tab-span"> </span>~z =<span class="Apple-converted-space">  </span>{ max(<span class="s5">SinOsc</span>.ar(<span class="s5">ExpRand</span>(3, 160)), <span class="s5">Saw</span>.ar([304, 304.3])) * 0.1 };</p>
144 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.play;<span class="Apple-tab-span"> </span></span>// monitor the proxy</p>
145 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.stop; </span>// note that now the proxy is still playing, but only in private</p>
146 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.isPlaying; </span>// is the group playing? yes.</p>
147 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.monitor.isPlaying; </span>// is the monitor playing? no.</p>
148 <p class="p2"><span class="Apple-tab-span"> </span></p>
149 <p class="p4"><span class="s9"><span class="Apple-tab-span"> </span></span>You can pass a vol argument to play to adjust the monitor volume without</p>
150 <p class="p4"><span class="Apple-tab-span"> </span>affecting the proxy internal bus volume.</p>
151 <p class="p3"><span class="Apple-tab-span"> </span></p>
152 <p class="p7"><span class="Apple-tab-span"> </span>~z.play(vol:0.3);</p>
153 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span></span>// while playing you can set the volume also:</p>
154 <p class="p7"><span class="Apple-tab-span"> </span>~z.vol = 0.8;</p>
155 <p class="p2"><span class="Apple-tab-span"> </span></p>
156 <p class="p2"><br></p>
157 <p class="p4"><b>send / release</b></p>
158 <p class="p2"><span class="Apple-tab-span"> </span></p>
159 <p class="p4"><span class="Apple-tab-span"> </span>this pair of messages controls the synths within the proxy. It does not</p>
160 <p class="p4"><span class="Apple-tab-span"> </span>affect the monitoring (see above). send starts a new synth, release releases the synth.</p>
161 <p class="p4"><span class="Apple-tab-span"> </span><b>send</b> by default releases the last synth. if the synth frees itself (doneAction 2) <b>spawn</b> can be used.</p>
162 <p class="p2"><span class="Apple-tab-span"> </span></p>
163 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span></span>// first hit cmd-period.</p>
164 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.play; </span>// monitor. this starts also the synth, if the group wasn't playing.</p>
165 <p class="p2"><span class="Apple-tab-span"> </span></p>
166 <p class="p7"><span class="Apple-tab-span"> </span>~z = { <span class="s5">SinOsc</span>.ar(<span class="s5">ExpRand</span>(20, 660) ! 2) * <span class="s5">Saw</span>.ar(<span class="s5">ExpRand</span>(200, 960) ! 2) * 0.1 };</p>
167 <p class="p2"><span class="Apple-tab-span"> </span></p>
168 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.release; </span>// release the synth. the current fadeTime is used for fade out</p>
169 <p class="p2"><span class="Apple-tab-span"> </span></p>
170 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.send; </span>// send a new synth. the current fadeTime is used for fade in</p>
171 <p class="p2"><span class="Apple-tab-span"> </span></p>
172 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.send; </span>// send another synth, release the old</p>
173 <p class="p2"><span class="Apple-tab-span"> </span></p>
174 <p class="p7"><span class="Apple-tab-span"> </span>~z.release;</p>
175 <p class="p2"><br></p>
176 <p class="p7"><span class="Apple-tab-span"> </span>~z.stop;</p>
177 <p class="p2"><span class="Apple-tab-span"> </span></p>
178 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.play; </span>// monitor. as the group was still playing, this does _not_ start the proxy.</p>
179 <p class="p2"><span class="Apple-tab-span"> </span></p>
180 <p class="p4"><span class="s9"><span class="Apple-tab-span"> </span></span>in order to free the synths and the group together,<span class="Apple-converted-space">  </span><b>free</b> is used:</p>
181 <p class="p2"><span class="Apple-tab-span"> </span></p>
182 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.free; </span>// this does also not affect the monitoring.</p>
183 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.play; </span>// monitor. as the group was not playing, this starts the proxy.</p>
184 <p class="p8"><br></p>
185 <p class="p8"><span class="Apple-tab-span"> </span></p>
186 <p class="p4"><span class="s10"><span class="Apple-tab-span"> </span></span>in order to free the synths and the group, stop playback, <b>end</b> is used.</p>
187 <p class="p3"><span class="Apple-tab-span"> </span></p>
188 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.end(3); </span>// end in 3 sec</p>
189 <p class="p8"><span class="Apple-tab-span"> </span></p>
190 <p class="p4"><span class="Apple-tab-span"> </span>in order to rebuild the synthdef on the server, use <b>rebuild</b>.<span class="Apple-converted-space"> </span></p>
191 <p class="p4"><span class="Apple-tab-span"> </span>this is of course far less efficient than <i>send</i>, but it can make sense;<span class="Apple-converted-space"> </span></p>
192 <p class="p4"><span class="Apple-tab-span"> </span>e.g. the synthdef has random elements.<span class="Apple-converted-space"> </span></p>
193 <p class="p4"><span class="Apple-tab-span"> </span>UGens like<span class="Apple-converted-space">  </span>Rand(300, 400) create new random values on every send,<span class="Apple-converted-space"> </span></p>
194 <p class="p4"><span class="Apple-tab-span"> </span>while client-side random functions like exprand(1, 1.3) only get built once;<span class="Apple-converted-space"> </span></p>
195 <p class="p4"><span class="Apple-tab-span"> </span>to force new decisions with these, one can use <b>rebuild</b>.</p>
196 <p class="p8"><span class="Apple-tab-span"> </span></p>
197 <p class="p6"><span class="Apple-tab-span"> </span>(</p>
198 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span>~z = {<span class="Apple-converted-space"> </span></p>
199 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Splay.ar(</p>
200 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s5"><span class="Apple-tab-span"> </span>SinOsc</span>.ar(Rand(300,400) + ({exprand(1, 1.3)} ! rrand(1, 9)))</p>
201 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>* <span class="s5">LFCub</span>.ar({exprand(30, 900)} ! rrand(1, 9))</p>
202 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>* LFSaw.kr({exprand(1.0, 8.0)} ! rrand(1, 9)).max(0)</p>
203 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>* 0.1</p>
204 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
205 <p class="p7"><span class="Apple-tab-span"> </span>};</p>
206 <p class="p7"><span class="Apple-tab-span"> </span>)</p>
207 <p class="p2"><span class="Apple-tab-span"> </span></p>
208 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span>~z.play;</p>
209 <p class="p7"><span class="Apple-tab-span"> </span>~z.rebuild;</p>
210 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.send;<span class="Apple-tab-span"> </span></span>// send just creates a new synth - new freq, all else remains the same</p>
211 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.rebuild; </span>// rebuild the synthdef, re-decide numbers of oscs<span class="Apple-converted-space"> </span></p>
212 <p class="p7"><span class="Apple-tab-span"> </span>~z.end;</p>
213 <p class="p8"><span class="Apple-tab-span"> </span></p>
214 <p class="p2"><span class="Apple-tab-span"> </span></p>
215 <p class="p2"><span class="Apple-tab-span"> </span></p>
216 <p class="p3"><br></p>
217 <p class="p4"><b>pause / resume</b></p>
218 <p class="p4"><span class="Apple-tab-span"> </span>when paused, a node proxy still stays active, but every synth that is started is paused until</p>
219 <p class="p4"><span class="Apple-tab-span"> </span>the proxy is resumed again.</p>
220 <p class="p3"><br></p>
221 <p class="p7"><span class="s11"><span class="Apple-tab-span"> </span></span>~z.play;</p>
222 <p class="p2"><span class="Apple-tab-span"> </span></p>
223 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.pause; </span>// pause the synth.</p>
224 <p class="p2"><span class="Apple-tab-span"> </span></p>
225 <p class="p7"><span class="Apple-tab-span"> </span>~z = { <span class="s5">SinOsc</span>.ar({<span class="s5">ExpRand</span>(300, 660)} ! 2) * 0.1 }; <span class="Apple-tab-span"> </span><span class="s7">// you can add a new function,<span class="Apple-converted-space"> </span></span></p>
226 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// which is paused.</p>
227 <p class="p2"><span class="Apple-tab-span"> </span></p>
228 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.resume; </span>// resume playing.</p>
229 <p class="p8"><span class="Apple-tab-span"> </span></p>
230 <p class="p8"><span class="Apple-tab-span"> </span></p>
231 <p class="p4"><span class="Apple-tab-span"> </span>Note that pause/resume causes clicks with audio rate proxies, which do not<span class="Apple-converted-space"> </span></p>
232 <p class="p4"><span class="Apple-tab-span"> </span>happen when pauseing control rate proxies.</p>
233 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
234 <p class="p2"><br></p>
235 <p class="p2"><span class="Apple-tab-span"> </span></p>
236 <p class="p4"><b>clear</b><span class="Apple-tab-span"> </span></p>
237 <p class="p3"><br></p>
238 <p class="p4"><span class="Apple-tab-span"> </span>clear removes all synths, the group, the monitor and releases the bus number.</p>
239 <p class="p3"><br></p>
240 <p class="p7"><span class="s11"><span class="Apple-tab-span"> </span></span>~z.clear;</p>
241 <p class="p7"><span class="Apple-tab-span"> </span>~z.bus; <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">// no bus</span></p>
242 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span>~z.isNeutral; </span>// not initialized.</p>
243 <p class="p3"><span class="Apple-tab-span"> </span></p>
244 <p class="p4"><span class="Apple-tab-span"> </span>note that when other processes use the nodeproxy these are not notified. So clearing has to<span class="Apple-converted-space"> </span></p>
245 <p class="p4"><span class="Apple-tab-span"> </span>be done with regard to this.</p>
246 <p class="p3"><br></p>
247 <p class="p3"><br></p>
248 <p class="p3"><br></p>
249 <p class="p3"><br></p>
250 <p class="p3"><br></p>
251 <p class="p3"><br></p>
252 <p class="p3"><br></p>
253 <p class="p3"><br></p>
254 <p class="p3"><br></p>
255 <p class="p4"><b>d) The parameter context</b></p>
256 <p class="p3"><br></p>
257 <p class="p3"><br></p>
258 <p class="p4">what happens to function arguments?</p>
259 <p class="p3"><br></p>
260 <p class="p7"><span class="Apple-tab-span"> </span>~y.play;</p>
261 <p class="p7"><span class="Apple-tab-span"> </span>~y = { <span class="s5">arg</span> freq=500; <span class="s5">SinOsc</span>.ar(freq * [1, 1.1]) * 0.1 };</p>
262 <p class="p3"><span class="Apple-tab-span"> </span></p>
263 <p class="p4">now the argument 'freq' is a control in the synth (just like in SynthDef) which you can change by the '<b>set</b>' message.</p>
264 <p class="p3"><br></p>
265 <p class="p7"><span class="Apple-tab-span"> </span>~y.set(<span class="s12">\freq</span>, 440);</p>
266 <p class="p3"><span class="Apple-tab-span"> </span></p>
267 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span></span>// unlike in synths, this context is kept and applied to every new synth:</p>
268 <p class="p3"><br></p>
269 <p class="p7"><span class="Apple-tab-span"> </span>~y = { <span class="s5">arg</span> freq=500; <span class="s5">Formant</span>.ar(50, freq * [1, 1.1], 70) * 0.1 };</p>
270 <p class="p3"><br></p>
271 <p class="p4"><b>xset</b> is a variant of set, to crossfade the change using the current fadeTime:</p>
272 <p class="p3"><br></p>
273 <p class="p7"><span class="Apple-tab-span"> </span>~y.fadeTime = 3;</p>
274 <p class="p7"><span class="Apple-tab-span"> </span>~y.xset(<span class="s12">\freq</span>, 600);</p>
275 <p class="p3"><span class="Apple-tab-span"> </span></p>
276 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span></span>// the same context is applied to all slots:</p>
277 <p class="p2"><br></p>
278 <p class="p7"><span class="Apple-tab-span"> </span>~y[2] = { <span class="s5">arg</span> freq=500; <span class="s5">SinOsc</span>.ar(freq * [1, 1.1]) * LFPulse.kr(Rand(1, 3)) * 0.1 };</p>
279 <p class="p7"><span class="Apple-tab-span"> </span>~y.xset(<span class="s12">\freq</span>, 300);</p>
280 <p class="p3"><br></p>
281 <p class="p3"><span class="Apple-tab-span"> </span></p>
282 <p class="p4">the parameter context also can keep bus mappings. a control can be mapped to any <i>control proxy</i>:</p>
283 <p class="p3"><br></p>
284 <p class="p7"><span class="Apple-tab-span"> </span>~c = { <span class="s5">MouseX</span>.kr(300, 800, 1) };</p>
285 <p class="p7"><span class="Apple-tab-span"> </span>~y.map(<span class="s12">\freq</span>, ~c);</p>
286 <p class="p3"><span class="Apple-tab-span"> </span></p>
287 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span></span>// also here the context is kept:</p>
288 <p class="p2"><br></p>
289 <p class="p7"><span class="Apple-tab-span"> </span>~y = { <span class="s5">arg</span> freq=500; <span class="s5">Formant</span>.ar(4, freq * [1, 1.1], 70) * 0.1 };</p>
290 <p class="p3"><br></p>
291 <p class="p3"><br></p>
292 <p class="p4"><b>xmap </b>is a variant of map, to crossfade the change using the current fadeTime:</p>
293 <p class="p2"><span class="Apple-tab-span"> </span></p>
294 <p class="p7"><span class="Apple-tab-span"> </span>~y.set(<span class="s12">\freq</span>, 440);</p>
295 <p class="p7"><span class="Apple-tab-span"> </span>~y.xmap(<span class="s12">\freq</span>, ~c);</p>
296 <p class="p3"><br></p>
297 <p class="p3"><br></p>
298 <p class="p4">to remove a setting or a mapping, use <b>unmap / unset</b>.<span class="Apple-converted-space"> </span></p>
299 <p class="p3"><span class="Apple-tab-span"> </span></p>
300 <p class="p7"><span class="Apple-tab-span"> </span>~y.unmap;</p>
301 <p class="p2"><span class="Apple-tab-span"> </span></p>
302 <p class="p2"><br></p>
303 <p class="p3"><span class="Apple-tab-span"> </span></p>
304 <p class="p4">also multichannel controls can be mapped to a multichannel proxy using <b>map</b>:</p>
305 <p class="p3"><br></p>
306 <p class="p7"><span class="Apple-tab-span"> </span>~c2 =<span class="Apple-converted-space">  </span>{ [<span class="s5">MouseX</span>.kr(300, 800, 1), <span class="s5">MouseY</span>.kr(300, 800, 1)] };</p>
307 <p class="p7"><span class="Apple-tab-span"> </span>~y = { <span class="s5">arg</span> freq=#[440, 550]; <span class="s5">SinOsc</span>.ar(freq) * <span class="s5">SinOsc</span>.ar(freq + 3) * 0.05 };</p>
308 <p class="p7"><span class="Apple-tab-span"> </span>~y.map(<span class="s12">\freq</span>, ~c2);</p>
309 <p class="p3"><br></p>
310 <p class="p3"><br></p>
311 <p class="p4">the parameter context can be examined:</p>
312 <p class="p3"><br></p>
313 <p class="p7"><span class="Apple-tab-span"> </span>~y.nodeMap;</p>
314 <p class="p3"><br></p>
315 <p class="p6"><span class="Apple-tab-span"> </span>// apart from the parameters explicitly set,<span class="Apple-converted-space"> </span></p>
316 <p class="p6"><span class="Apple-tab-span"> </span>// it contains the bus index and the fadeTime</p>
317 <p class="p8"><span class="Apple-tab-span"> </span></p>
318 <p class="p6"><span class="Apple-tab-span"> </span>// for more information, see <a href="../nodeproxy/NodeMap.html"><span class="s13">NodeMap</span></a></p>
319 <p class="p3"><br></p>
320 <p class="p3"><br></p>
321 <p class="p6"><span class="s3">p.clear(8); </span>// clear the whole proxy space, in 8 secs.</p>
322 <p class="p2"><br></p>
323 <p class="p3"><br></p>
324 <p class="p3"><br></p>
325 <p class="p3"><br></p>
326 <p class="p5"><span class="s3">previous: <a href="jitlib_basic_concepts_02.html"><span class="s4">jitlib_basic_concepts_02</span></a> <span class="Apple-tab-span"> </span>next: <a href="jitlib_basic_concepts_04.html"><span class="s4">jitlib_basic_concepts_04</span></a><span class="Apple-converted-space"> </span></span></p>
327 <p class="p3"><br></p>
328 </body>
329 </html>