supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / UGens / Filters / Klank.html
blob82083303f96d889c9a4c69d63713127d081d07e2
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.41">
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: 12.0px Helvetica; min-height: 14.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 Monaco; min-height: 16.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; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #982316}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #982316; min-height: 12.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0025b2}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
20 span.s1 {color: #0000ff}
21 span.s2 {color: #0025b2}
22 span.s3 {color: #982316}
23 span.s4 {color: #000000}
24 span.s5 {color: #606060}
25 span.s6 {color: #416d1f}
26 span.Apple-tab-span {white-space:pre}
27 </style>
28 </head>
29 <body>
30 <p class="p1"><b>Klank<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>bank of resonators</b></p>
31 <p class="p2"><br></p>
32 <p class="p3"><b>Klank.ar(specificationsArrayRef, input, freqscale, freqoffset, decayscale)</b></p>
33 <p class="p2"><br></p>
34 <p class="p3">Klank is a bank of fixed frequency resonators which can be used to simulate the resonant modes of an object. Each mode is given a ring time, which is the time for the mode to decay by 60 dB.</p>
35 <p class="p2"><br></p>
36 <p class="p3">The parameters in <b>specificationsArrayRef</b> can't be changed after it has been started.<span class="Apple-converted-space"> </span></p>
37 <p class="p3">For a modulatable but less efficient version, see <a href="DynKlank.html"><span class="s1">DynKlank</span></a>.</p>
38 <p class="p2"><br></p>
39 <p class="p3"><b>specificationsArrayRef</b> - a Ref to an Array of three Arrays :</p>
40 <p class="p3"><span class="Apple-tab-span"> </span><b>frequencies</b> - an Array of filter frequencies.</p>
41 <p class="p3"><span class="Apple-tab-span"> </span><b>amplitudes</b> - an Array of filter amplitudes, or nil. If nil, then amplitudes default to 1.0</p>
42 <p class="p3"><span class="Apple-tab-span"> </span><b>ring</b> <b>times</b> - an Array of 60 dB decay times for the filters.</p>
43 <p class="p3">All subarrays, if not nil, should have the same length.</p>
44 <p class="p3"><b>input</b> - the excitation input to the resonant filter bank.</p>
45 <p class="p3"><b>freqscale</b> - a scale factor multiplied by all frequencies at initialization time.</p>
46 <p class="p3"><b>freqoffset</b> - an offset added to all frequencies at initialization time.</p>
47 <p class="p3"><b>decayscale</b> - a scale factor multiplied by all ring times at initialization time.</p>
48 <p class="p4"><br></p>
49 <p class="p5">{ <span class="s2">Klank</span>.ar(`[[800, 1071, 1153, 1723], <span class="s2">nil</span>, [1, 1, 1, 1]], <span class="s2">Impulse</span>.ar(2, 0, 0.1)) }.play;</p>
50 <p class="p6"><br></p>
51 <p class="p5">{ <span class="s2">Klank</span>.ar(`[[800, 1071, 1353, 1723], <span class="s2">nil</span>, [1, 1, 1, 1]], <span class="s2">Dust</span>.ar(8, 0.1)) }.play;</p>
52 <p class="p6"><br></p>
53 <p class="p5">{ <span class="s2">Klank</span>.ar(`[[800, 1071, 1353, 1723], <span class="s2">nil</span>, [1, 1, 1, 1]], <span class="s2">PinkNoise</span>.ar(0.007)) }.play;</p>
54 <p class="p6"><br></p>
55 <p class="p5">{ <span class="s2">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s2">nil</span>, [1, 1, 1, 1]], <span class="s2">PinkNoise</span>.ar([0.007,0.007])) }.play;</p>
56 <p class="p6"><br></p>
57 <p class="p5">(</p>
58 <p class="p5">play({</p>
59 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">Klank</span>.ar(`[<span class="Apple-converted-space"> </span></p>
60 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Array</span>.rand(12, 800.0, 4000.0),<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">// frequencies</span></p>
61 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">nil</span><span class="s4">,<span class="Apple-converted-space">  <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></span>// amplitudes (default to 1.0)</p>
62 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Array</span>.rand(12, 0.1, 2)<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="s3">// ring times</span></p>
63 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>], <span class="s2">Decay</span>.ar(<span class="s2">Impulse</span>.ar(4), 0.03, <span class="s2">ClipNoise</span>.ar(0.01)))</p>
64 <p class="p5">})</p>
65 <p class="p5">)</p>
66 <p class="p6"><br></p>
67 <p class="p6"><br></p>
68 <p class="p6"><br></p>
69 <p class="p7">// a synth def that has 4 partials</p>
70 <p class="p5">(</p>
71 <p class="p5">s = <span class="s2">Server</span>.local;</p>
72 <p class="p5"><span class="s2">SynthDef</span>(<span class="s5">"help-Control"</span>, { <span class="s2">arg</span> out=0,i_freq;</p>
73 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> klank, n, harm, amp, ring;</p>
74 <p class="p6"><span class="Apple-tab-span"> </span></p>
75 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span></span>// harmonics</p>
76 <p class="p5"><span class="Apple-tab-span"> </span>harm = <span class="s2">Control</span>.names([<span class="s6">\harm</span>]).ir(<span class="s2">Array</span>.series(4,1,1).postln);</p>
77 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span></span>// amplitudes</p>
78 <p class="p5"><span class="Apple-tab-span"> </span>amp = <span class="s2">Control</span>.names([<span class="s6">\amp</span>]).ir(<span class="s2">Array</span>.fill(4,0.05));</p>
79 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span></span>// ring times</p>
80 <p class="p5"><span class="Apple-tab-span"> </span>ring = <span class="s2">Control</span>.names([<span class="s6">\ring</span>]).ir(<span class="s2">Array</span>.fill(4,1));</p>
81 <p class="p6"><span class="Apple-tab-span"> </span></p>
82 <p class="p5"><span class="Apple-tab-span"> </span>klank = <span class="s2">Klank</span>.ar(`[harm,amp,ring], {<span class="s2">ClipNoise</span>.ar(0.003)}.dup, i_freq);</p>
83 <p class="p6"><span class="Apple-tab-span"> </span></p>
84 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(out, klank);</p>
85 <p class="p5">}).send(s);</p>
86 <p class="p5">)</p>
87 <p class="p6"><br></p>
88 <p class="p7">// nothing special yet, just using the default set of harmonics.</p>
89 <p class="p5">a = <span class="s2">Synth</span>(<span class="s5">"help-Control"</span>,[<span class="s6">\i_freq</span>, 300]);</p>
90 <p class="p5">b = <span class="s2">Synth</span>(<span class="s5">"help-Control"</span>,[<span class="s6">\i_freq</span>, 400]);</p>
91 <p class="p5">c = <span class="s2">Synth</span>(<span class="s5">"help-Control"</span>,[<span class="s6">\i_freq</span>, 533.33]);</p>
92 <p class="p5">d = <span class="s2">Synth</span>(<span class="s5">"help-Control"</span>,[<span class="s6">\i_freq</span>, 711.11]);</p>
93 <p class="p6"><br></p>
94 <p class="p5">a.free;</p>
95 <p class="p5">b.free;</p>
96 <p class="p5">c.free;</p>
97 <p class="p5">d.free;</p>
98 <p class="p6"><br></p>
99 <p class="p7">// in order to set the harmonics amps and ring times at</p>
100 <p class="p7">// initialization time we need to use an OSC bundle.</p>
101 <p class="p5">(</p>
102 <p class="p5">s.sendBundle(<span class="s2">nil</span>,</p>
103 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/s_new"</span>, <span class="s5">"help-Control"</span>, 2000, 1, 0, <span class="s6">\i_freq</span>, 500], <span class="s3">// start note</span></p>
104 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/n_setn"</span>, 2000, <span class="s5">"harm"</span>, 4, 1, 3, 5, 7] <span class="s3">// set odd harmonics</span></p>
105 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
106 <p class="p5">)</p>
107 <p class="p6"><br></p>
108 <p class="p5">s.sendMsg(<span class="s5">"/n_free"</span>, 2000);</p>
109 <p class="p6"><br></p>
110 <p class="p5">(</p>
111 <p class="p5">s.sendBundle(<span class="s2">nil</span>,</p>
112 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/s_new"</span>, <span class="s5">"help-Control"</span>, 2000, 1, 0, <span class="s6">\i_freq</span>, 500], <span class="s3">// start note</span></p>
113 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span></span>// set geometric series harmonics</p>
114 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/n_setn"</span>, 2000, <span class="s5">"harm"</span>, 4] ++ <span class="s2">Array</span>.geom(4,1,1.61)</p>
115 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
116 <p class="p5">)</p>
117 <p class="p6"><br></p>
118 <p class="p5">s.sendMsg(<span class="s5">"/n_free"</span>, 2000);</p>
119 <p class="p6"><br></p>
120 <p class="p5">(</p>
121 <p class="p7">// set harmonics, ring times and amplitudes</p>
122 <p class="p5">s.sendBundle(<span class="s2">nil</span>,</p>
123 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/s_new"</span>, <span class="s5">"help-Control"</span>, 2000, 1, 0, <span class="s6">\i_freq</span>, 500], <span class="s3">// start note</span></p>
124 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/n_setn"</span>, 2000, <span class="s5">"harm"</span>, 4, 1, 3, 5, 7], <span class="s3">// set odd harmonics</span></p>
125 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/n_setn"</span>, 2000, <span class="s5">"ring"</span>, 4] ++ <span class="s2">Array</span>.fill(4,0.1), <span class="s3">// set shorter ring time</span></p>
126 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/n_setn"</span>, 2000, <span class="s5">"amp"</span>, 4] ++ <span class="s2">Array</span>.fill(4,0.2) <span class="s3">// set louder amps</span></p>
127 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
128 <p class="p5">)</p>
129 <p class="p6"><br></p>
130 <p class="p5">s.sendMsg(<span class="s6">\n_trace</span>, 2000);</p>
131 <p class="p5">s.sendMsg(<span class="s5">"/n_free"</span>, 2000);</p>
132 <p class="p6"><br></p>
133 <p class="p5">(</p>
134 <p class="p7">// same effect as above, but packed into one n_setn command</p>
135 <p class="p5">s.sendBundle(<span class="s2">nil</span>,</p>
136 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/s_new"</span>, <span class="s5">"help-Control"</span>, 2000, 1, 0, <span class="s6">\i_freq</span>, 500], <span class="s3">// start note</span></p>
137 <p class="p5"><span class="Apple-tab-span"> </span>[<span class="s5">"/n_setn"</span>, 2000, <span class="s5">"harm"</span>, 4, 1, 3, 5, 7,</p>
138 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s5">"ring"</span>, 4] ++ <span class="s2">Array</span>.fill(4,0.1)</p>
139 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>++ [<span class="s5">"amp"</span>, 4] ++ <span class="s2">Array</span>.fill(4,0.2)</p>
140 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
141 <p class="p5">)</p>
142 <p class="p6"><br></p>
143 <p class="p5">s.sendMsg(<span class="s5">"/n_free"</span>, 2000);</p>
144 <p class="p6"><br></p>
145 <p class="p6"><br></p>
146 <p class="p8"><br></p>
147 <p class="p8"><br></p>
148 <p class="p7">//////////////////////////////////////////////////////////////////////</p>
149 <p class="p6"><br></p>
150 <p class="p7">//-- overlap texture</p>
151 <p class="p5">(</p>
152 <p class="p9">SynthDef<span class="s4">(</span><span class="s5">"help-KlankOverlapTexture"</span><span class="s4">, {</span>|out = 0, freqs = #[0,0,0,0,0,0,0,0,0,0,0,0], rings = #[0,0,0,0,0,0,0,0,0,0,0,0], atk = 5, sus = 8, rel = 5, pan = 0|</p>
153 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> e = <span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>.linen(atk, sus, rel, 1, 4), doneAction:2);</p>
154 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> i = <span class="s2">Decay</span>.ar(<span class="s2">Impulse</span>.ar(<span class="s2">Rand</span>(0.8, 2.2)), 0.03, <span class="s2">ClipNoise</span>.ar(0.01));</p>
155 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> z = <span class="s2">Klank</span>.ar(</p>
156 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>`[freqs, <span class="s2">nil</span>, rings],<span class="Apple-tab-span"> </span><span class="s3">// specs</span></p>
157 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i<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="s3">// input</span></p>
158 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
159 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(out, <span class="s2">Pan2</span>.ar(z*e, pan));</p>
160 <p class="p5">}).send(s);</p>
161 <p class="p6"><br></p>
162 <p class="p9"><span class="s4">r = </span>Routine<span class="s4">{</span></p>
163 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> sustain = 8, transition = 3, overlap = 4;</p>
164 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> period = transition*2+sustain/overlap;</p>
165 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span>0.5.wait;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//wait for the synthdef to be sent to the server</p>
166 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">inf</span>.do{</p>
167 <p class="p10"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Synth</span><span class="s4">(</span>"help-KlankOverlapTexture"<span class="s4">, [</span></p>
168 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\atk</span>, transition,</p>
169 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\sus</span>, sustain,</p>
170 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\rel</span>, transition,</p>
171 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\pan</span>, 1.0.rand2</p>
172 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>]).setn(</p>
173 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\freqs</span>, {200.0.rrand(4000)}.dup(12),</p>
174 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\rings</span>, {0.1.rrand(2)}.dup(12)</p>
175 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
176 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>period.wait;</p>
177 <p class="p5"><span class="Apple-tab-span"> </span>}</p>
178 <p class="p5">};</p>
179 <p class="p5">r.play;</p>
180 <p class="p5">)</p>
181 <p class="p6"><br></p>
182 <p class="p7"><span class="s4">r.stop;<span class="Apple-tab-span"> </span></span>//stop spawning new synths</p>
183 <p class="p6"><br></p>
184 <p class="p6"><br></p>
185 <p class="p6"><br></p>
186 <p class="p7">//-- frequency and decay scaling</p>
187 <p class="p5">(</p>
188 <p class="p9">SynthDef<span class="s4">(</span><span class="s5">"help-KlankScaling"</span><span class="s4">, {</span>|out = 0, freq = 0, rings = #[0,0,0,0,0,0,0,0,0,0,0,0], pan = 0|</p>
189 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> e = <span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>(#[1, 1, 0], #[0.4, 0.01]), doneAction:2);</p>
190 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> i = <span class="s2">Decay</span>.ar(<span class="s2">Impulse</span>.ar(0), 0.03, <span class="s2">ClipNoise</span>.ar(0.01));</p>
191 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> z = <span class="s2">Klank</span>.ar(</p>
192 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>`[(1..12), </span><span class="s2">nil</span><span class="s4">, rings],<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>// specs (partials, amplitudes, ringtimes)</p>
193 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i,<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="s3">// input</span></p>
194 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>freq,<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>// scale to this frequency</p>
195 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0,<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>// frequency offset</p>
196 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">MouseX</span><span class="s4">.kr(0.2, 3)<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>// scale decay times</p>
197 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
198 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(out, <span class="s2">Pan2</span>.ar(z*e, pan));</p>
199 <p class="p5">}).send(s);</p>
200 <p class="p6"><br></p>
201 <p class="p9"><span class="s4">r = </span>Routine<span class="s4">{</span></p>
202 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> sustain = 8, transition = 3;</p>
203 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> mode = #[0, 2, 4, 5, 7, 9, 11, 12, 14, 16, 17, 19, 21, 23, 24];</p>
204 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span>0.5.wait;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//wait for the synthdef to be sent to the server</p>
205 <p class="p9"><span class="s4"><span class="Apple-tab-span"> </span></span>inf<span class="s4">.do{</span>|i|</p>
206 <p class="p10"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Synth</span><span class="s4">(</span>"help-KlankScaling"<span class="s4">, [</span></p>
207 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\freq</span>, (72 + (mode @@ i)).midicps</p>
208 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>]).setn(<span class="s6">\rings</span>, {0.1.rrand(2)}.dup(12));</p>
209 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0.2.wait;</p>
210 <p class="p5"><span class="Apple-tab-span"> </span>}</p>
211 <p class="p5">};</p>
212 <p class="p5">r.play;</p>
213 <p class="p5">)</p>
214 <p class="p6"><br></p>
215 <p class="p5">r.stop;</p>
216 <p class="p6"><br></p>
217 <p class="p6"><br></p>
218 <p class="p7">//-- overlap texture 2</p>
219 <p class="p5">(</p>
220 <p class="p9">SynthDef<span class="s4">(</span><span class="s5">"help-KlankOverlapTexture2"</span><span class="s4">, {</span>|out = 0, freqs = #[0,0,0,0,0,0,0,0,0,0,0,0], rings = #[0,0,0,0,0,0,0,0,0,0,0,0], atk = 5, sus = 8, rel = 5, pan = 0|</p>
221 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> e = <span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>.linen(atk, sus, rel, 1, 4), doneAction:2);</p>
222 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> i = <span class="s2">BrownNoise</span>.ar(0.0012);</p>
223 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> z = <span class="s2">Klank</span>.ar(</p>
224 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>`[freqs, <span class="s2">nil</span>, rings],<span class="Apple-tab-span"> </span><span class="s3">// specs</span></p>
225 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i<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="s3">// input</span></p>
226 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
227 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(out, <span class="s2">Pan2</span>.ar(z*e, pan));</p>
228 <p class="p5">}).send(s);</p>
229 <p class="p6"><br></p>
230 <p class="p9"><span class="s4">r = </span>Routine<span class="s4">{</span></p>
231 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> sustain = 6, transition = 4, overlap = 5;</p>
232 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> period = transition*2+sustain/overlap;</p>
233 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span>0.5.wait;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//wait for the synthdef to be sent to the server</p>
234 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">inf</span>.do{</p>
235 <p class="p10"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Synth</span><span class="s4">(</span>"help-KlankOverlapTexture2"<span class="s4">, [</span></p>
236 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\atk</span>, transition,</p>
237 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\sus</span>, sustain,</p>
238 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\rel</span>, transition,</p>
239 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\pan</span>, 1.0.rand2</p>
240 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>]).setn(</p>
241 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\freqs</span>, {6000.0.linrand+80}.dup(12),</p>
242 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\rings</span>, {0.1.rrand(3)}.dup(12)</p>
243 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
244 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>period.wait;</p>
245 <p class="p5"><span class="Apple-tab-span"> </span>}</p>
246 <p class="p5">};</p>
247 <p class="p5">r.play;</p>
248 <p class="p5">)</p>
249 <p class="p6"><br></p>
250 <p class="p5">r.stop;</p>
251 <p class="p6"><br></p>
252 <p class="p6"><br></p>
253 <p class="p7">//-- overlap texture 3</p>
254 <p class="p5">(</p>
255 <p class="p9">SynthDef<span class="s4">(</span><span class="s5">"help-KlankOverlapTexture3"</span><span class="s4">, {</span>|out = 0, freqs = #[0,0,0,0,0,0,0,0,0,0,0,0], rings = #[0,0,0,0,0,0,0,0,0,0,0,0], pan = 0|</p>
256 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> e = <span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>(#[1, 1, 0], #[18, 3]), doneAction:2);</p>
257 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> i = <span class="s2">Decay</span>.ar(<span class="s2">Impulse</span>.ar(<span class="s2">Rand</span>(0.2, 0.6)), 0.8, <span class="s2">ClipNoise</span>.ar(0.001));</p>
258 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">var</span> z = <span class="s2">Klank</span>.ar(</p>
259 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>`[freqs, <span class="s2">2</span>, rings],<span class="Apple-tab-span"> </span><span class="s3">// specs</span></p>
260 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i<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="s3">// input</span></p>
261 <p class="p5"><span class="Apple-tab-span"> </span>);</p>
262 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(out, <span class="s2">Pan2</span>.ar(z*e, pan));</p>
263 <p class="p5">}).send(s);</p>
264 <p class="p6"><br></p>
265 <p class="p9"><span class="s4">r = </span>Routine<span class="s4">{</span></p>
266 <p class="p7"><span class="s4"><span class="Apple-tab-span"> </span>0.5.wait;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//wait for the synthdef to be sent to the server</p>
267 <p class="p5"><span class="Apple-tab-span"> </span><span class="s2">inf</span>.do{</p>
268 <p class="p10"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Synth</span><span class="s4">(</span>"help-KlankOverlapTexture3"<span class="s4">, [</span></p>
269 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\pan</span>, 1.0.rand2</p>
270 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>]).setn(</p>
271 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\freqs</span>, {12000.0.linrand+80}.dup(12),</p>
272 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s6">\rings</span>, {3.rrand(10)}.dup(12)</p>
273 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>);</p>
274 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>3.wait;</p>
275 <p class="p5"><span class="Apple-tab-span"> </span>}</p>
276 <p class="p5">};</p>
277 <p class="p5">r.play;</p>
278 <p class="p5">)</p>
279 <p class="p6"><br></p>
280 <p class="p5">r.stop;</p>
281 <p class="p6"><br></p>
282 </body>
283 </html>