cmake build system: visiblity support for clang
[supercollider.git] / Help / UGens / Tour_of_UGens.html
blobfca8e4915cb8859498e533f77585ea5db9a30c15
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.54">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 19.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #0021e7}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #77301f}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 4.0px Monaco; min-height: 5.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 3.0px Monaco; min-height: 4.0px}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #606060}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 3.0px Monaco; color: #183fac; min-height: 4.0px}
24 p.p15 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #ad140d}
25 p.p16 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
26 p.p17 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #183fac}
27 span.s1 {font: 14.0px Monaco; color: #0022b7}
28 span.s2 {font: 14.0px Monaco}
29 span.s3 {color: #183fac}
30 span.s4 {text-decoration: underline}
31 span.s5 {color: #000000}
32 span.s6 {color: #77301f}
33 span.s7 {text-decoration: underline ; color: #0021e7}
34 span.s8 {color: #556528}
35 span.s9 {color: #0f4ae6}
36 span.s10 {text-decoration: underline ; color: #003de5}
37 span.s11 {font: 12.0px Helvetica}
38 span.s12 {color: #001bb9}
39 span.s13 {font: 12.0px Monaco}
40 span.Apple-tab-span {white-space:pre}
41 </style>
42 </head>
43 <body>
44 <p class="p1"><b>Signal Processing</b> in SuperCollider</p>
45 <p class="p2"><br></p>
46 <p class="p3"><b>1. A Tour of available Unit Generators.</b></p>
47 <p class="p3"><span class="Apple-tab-span"> </span>SuperCollider has over 250 unit generators.<span class="Apple-converted-space"> </span></p>
48 <p class="p3"><span class="Apple-tab-span"> </span>If you count the unary and binary operators, there are over 300.<span class="Apple-converted-space"> </span></p>
49 <p class="p3"><span class="Apple-tab-span"> </span>This tour covers many, but not all of them.</p>
50 <p class="p2"><span class="Apple-tab-span"> </span></p>
51 <p class="p3"><span class="Apple-tab-span"> </span>categories of unit generators:<span class="Apple-converted-space"> </span></p>
52 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>sources: periodic, aperiodic<span class="Apple-converted-space"> </span></p>
53 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>filters</p>
54 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>distortion<span class="Apple-converted-space"> </span></p>
55 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>panning</p>
56 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>reverbs</p>
57 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>delays and buffer ugens</p>
58 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>granular synthesis</p>
59 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>control: envelopes, triggers, counters, gates, lags, decays</p>
60 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>spectral<span class="Apple-converted-space"> </span></p>
61 <p class="p2"><br></p>
62 <p class="p3"><b>2. Techniques<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
63 <p class="p3"><span class="Apple-tab-span"> </span>broadening a sound:<span class="Apple-converted-space"> </span></p>
64 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>decorrelation, beat frequencies, delays.</p>
65 <p class="p3"><span class="Apple-tab-span"> </span>series and parallel structures.</p>
66 <p class="p2"><br></p>
67 <p class="p3"><i>Note:</i> The "Help browser" (<span class="s1">Help</span><span class="s2">.gui</span>) contains a category for UGens, which provides another useful way to get an overview of the available UGens, including those which were created since this tour was written.</p>
68 <p class="p2"><br></p>
69 <p class="p4">(</p>
70 <p class="p4">s = <span class="s3">Server</span>.internal;</p>
71 <p class="p4"><span class="s3">Server</span>.default = s;</p>
72 <p class="p4">s.boot;</p>
73 <p class="p4">)</p>
74 <p class="p2"><br></p>
75 <p class="p3"><b>Periodic Sources: Oscillators.</b></p>
76 <p class="p2"><br></p>
77 <p class="p3"><b>LF - "Low Frequency" Unit Generators.</b></p>
78 <p class="p2"><br></p>
79 <p class="p3">LFPar, LFCub, LFTri, Impulse, LFSaw, LFPulse, VarSaw, SyncSaw</p>
80 <p class="p2"><br></p>
81 <p class="p3">geometric waveforms, not band limited.</p>
82 <p class="p3">will cause aliasing at higher frequencies.</p>
83 <p class="p2"><br></p>
84 <p class="p2"><br></p>
85 <p class="p5"><span class="s4"><a href="Oscillators/LFPar.html">LFPar</a></span><span class="s5">, <a href="Oscillators/LFCub.html"><span class="s4">LFCub</span></a>, <a href="Oscillators/LFTri.html"><span class="s4">LFTri</span></a>, <a href="Oscillators/LFSaw.html"><span class="s4">LFSaw</span></a>, <a href="Oscillators/Impulse.html"><span class="s4">Impulse</span></a></span></p>
86 <p class="p3">arguments:<span class="Apple-converted-space">  </span>frequency, phase, mul, add</p>
87 <p class="p2"><br></p>
88 <p class="p6">// parabolic approximation of sine</p>
89 <p class="p4">{ <span class="s3">LFPar</span>.ar(<span class="s3">LFPar</span>.kr(<span class="s3">LFPar</span>.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
90 <p class="p4">{ <span class="s3">LFPar</span>.ar(<span class="s3">LFPar</span>.kr(0.2, 0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
91 <p class="p4">{ <span class="s3">LFPar</span>.ar(800,0,0.1) }.scope(1, zoom: 4);</p>
92 <p class="p6">// since it is not band limited, there are aliasing artifacts</p>
93 <p class="p4">{ <span class="s3">LFPar</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.1) }.scope(1, zoom: 4);</p>
94 <p class="p7"><br></p>
95 <p class="p6">// cubic approximation of sine</p>
96 <p class="p4">{ <span class="s3">LFCub</span>.ar(<span class="s3">LFCub</span>.kr(<span class="s3">LFCub</span>.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
97 <p class="p4">{ <span class="s3">LFCub</span>.ar(<span class="s3">LFCub</span>.kr(0.2, 0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
98 <p class="p4">{ <span class="s3">LFCub</span>.ar(800,0,0.1) }.scope(1, zoom: 4);</p>
99 <p class="p4">{ <span class="s3">LFCub</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.1) }.scope(1, zoom: 4);</p>
100 <p class="p7"><br></p>
101 <p class="p7"><br></p>
102 <p class="p4">{ <span class="s3">LFTri</span>.ar(<span class="s3">LFTri</span>.kr(<span class="s3">LFTri</span>.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
103 <p class="p4">{ <span class="s3">LFTri</span>.ar(<span class="s3">LFTri</span>.kr(0.2, 0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
104 <p class="p4">{ <span class="s3">LFTri</span>.ar(800,0,0.1) }.scope(1, zoom: 4);</p>
105 <p class="p4">{ <span class="s3">LFTri</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.1) }.scope(1, zoom: 4);</p>
106 <p class="p7"><br></p>
107 <p class="p7"><br></p>
108 <p class="p4">{ <span class="s3">LFSaw</span>.ar(<span class="s3">LFSaw</span>.kr(<span class="s3">LFSaw</span>.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
109 <p class="p4">{ <span class="s3">LFSaw</span>.ar(<span class="s3">LFSaw</span>.kr(0.2, 0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
110 <p class="p4">{ <span class="s3">LFSaw</span>.ar(100,0,0.1) }.scope(1, zoom: 4);</p>
111 <p class="p4">{ <span class="s3">LFSaw</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.1) }.scope(1, zoom: 4);</p>
112 <p class="p7"><br></p>
113 <p class="p7"><br></p>
114 <p class="p4">{ <span class="s3">Impulse</span>.ar(<span class="s3">LFTri</span>.kr(<span class="s3">LFTri</span>.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
115 <p class="p4">{ <span class="s3">Impulse</span>.ar(<span class="s3">LFTri</span>.kr(0.2, 0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
116 <p class="p4">{ <span class="s3">Impulse</span>.ar(100,0,0.1) }.scope(1, zoom: 4);</p>
117 <p class="p4">{ <span class="s3">Impulse</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.1) }.scope(1, zoom: 4);</p>
118 <p class="p8"><br></p>
119 <p class="p5"><span class="s4"><a href="Oscillators/LFPulse.html">LFPulse</a></span><span class="s5">, <a href="Oscillators/VarSaw.html"><span class="s4">VarSaw</span></a></span></p>
120 <p class="p3">arguments:<span class="Apple-converted-space">  </span>frequency, phase, width, mul, add</p>
121 <p class="p8"><br></p>
122 <p class="p4">{ <span class="s3">LFPulse</span>.ar(<span class="s3">LFPulse</span>.kr(<span class="s3">LFPulse</span>.kr(0.2,0,0.5,8,10),0,0.5, 400,800),0,0.5,0.1) }.scope(1, zoom: 4);</p>
123 <p class="p4">{ <span class="s3">LFPulse</span>.ar(<span class="s3">LFPulse</span>.kr(3, 0, 0.3, 200, 200), 0, 0.2, 0.1) }.scope(1, zoom: 4);</p>
124 <p class="p4">{ <span class="s3">LFPulse</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.5,0.1) }.scope(1, zoom: 4);</p>
125 <p class="p7"><br></p>
126 <p class="p6">// pulse width modulation</p>
127 <p class="p4">{ <span class="s3">LFPulse</span>.ar(100,0,<span class="s3">MouseY</span>.kr(0,1),0.1) }.scope(1, zoom: 4);</p>
128 <p class="p4">{ <span class="s3">LFPulse</span>.ar(100,0,<span class="s3">LFTri</span>.kr(0.2,0,0.5,0.5),0.1) }.scope(1, zoom: 4);</p>
129 <p class="p7"><br></p>
130 <p class="p7"><br></p>
131 <p class="p4">{ <span class="s3">VarSaw</span>.ar(<span class="s3">VarSaw</span>.kr(<span class="s3">VarSaw</span>.kr(0.2,0,0.2,8,10),0,0.2, 400,800),0,0.2,0.1) }.scope(1, zoom: 4);</p>
132 <p class="p4">{ <span class="s3">VarSaw</span>.ar(<span class="s3">VarSaw</span>.kr(0.2, 0, 0.2, 400,800),0,0.2,0.1) }.scope(1, zoom: 4);</p>
133 <p class="p4">{ <span class="s3">VarSaw</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.2,0.1) }.scope(1, zoom: 4);</p>
134 <p class="p7"><br></p>
135 <p class="p6">// pulse width modulation</p>
136 <p class="p4">{ <span class="s3">VarSaw</span>.ar(100,0,<span class="s3">MouseY</span>.kr(0,1),0.1) }.scope(1, zoom: 4);</p>
137 <p class="p4">{ <span class="s3">VarSaw</span>.ar(100,0,<span class="s3">LFTri</span>.kr(0.2,0,0.5,0.5),0.1) }.scope(1, zoom: 4);</p>
138 <p class="p8"><br></p>
139 <p class="p5"><span class="s4"><a href="Oscillators/SyncSaw.html">SyncSaw</a></span></p>
140 <p class="p3">arguments:<span class="Apple-converted-space">  </span>syncFreq, sawFreq, mul, add</p>
141 <p class="p8"><br></p>
142 <p class="p4">{ <span class="s3">SyncSaw</span>.ar(100, <span class="s3">MouseX</span>.kr(100, 1000), 0.1) }.scope(1, zoom: 4);</p>
143 <p class="p4">{ <span class="s3">SyncSaw</span>.ar(100, <span class="s3">Line</span>.kr(100, 800, 12), 0.1) }.scope(1, zoom: 4);</p>
144 <p class="p8"><br></p>
145 <p class="p8"><br></p>
146 <p class="p3"><b>Band Limited Oscillators</b></p>
147 <p class="p2"><br></p>
148 <p class="p3">SinOsc, FSinOsc, Blip, Saw, Pulse</p>
149 <p class="p3">will not alias.<span class="Apple-converted-space"> </span></p>
150 <p class="p8"><br></p>
151 <p class="p5"><span class="s4"><a href="Oscillators/SinOsc.html">SinOsc</a></span><span class="s5">, <a href="Oscillators/FSinOsc.html"><span class="s4">FSinOsc</span></a></span></p>
152 <p class="p3">arguments:<span class="Apple-converted-space">  </span>frequency, phase, mul, add</p>
153 <p class="p8"><br></p>
154 <p class="p4">{ <span class="s3">SinOsc</span>.ar(<span class="s3">SinOsc</span>.kr(<span class="s3">SinOsc</span>.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
155 <p class="p4">{ <span class="s3">SinOsc</span>.ar(<span class="s3">SinOsc</span>.kr(0.2, 0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
156 <p class="p4">{ <span class="s3">SinOsc</span>.ar(800,0,0.1) }.scope(1, zoom: 4);</p>
157 <p class="p4">{ <span class="s3">SinOsc</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0,0.1) }.scope(1, zoom: 4);</p>
158 <p class="p7"><br></p>
159 <p class="p4">{ <span class="s3">FSinOsc</span>.ar(800,0,0.1) }.scope(1, zoom: 4);</p>
160 <p class="p6">// FSinOsc should not be frequency modulated.<span class="Apple-converted-space"> </span></p>
161 <p class="p6">// Since it is based on a filter at the edge of stability, it will blow up:</p>
162 <p class="p4">{ <span class="s3">FSinOsc</span>.ar(<span class="s3">FSinOsc</span>.kr(<span class="s3">FSinOsc</span>.kr(0.2,0,8,10),0, 400,800),0,0.1) }.scope(1, zoom: 4);</p>
163 <p class="p8"><br></p>
164 <p class="p5"><span class="s4"><a href="Oscillators/Blip.html">Blip</a></span></p>
165 <p class="p3">arguments:<span class="Apple-converted-space">  </span>frequency, numHarmonics, mul, add</p>
166 <p class="p2"><br></p>
167 <p class="p4">{ <span class="s3">Blip</span>.ar(<span class="s3">XLine</span>.kr(20000,200,6),100,0.2) }.scope(1);</p>
168 <p class="p4">{ <span class="s3">Blip</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),100,0.2) }.scope(1); <span class="s6">// no aliasing</span></p>
169 <p class="p6">// modulate number of harmonics</p>
170 <p class="p4">{ <span class="s3">Blip</span>.ar(200,<span class="s3">Line</span>.kr(1,100,20),0.2) }.scope(1);</p>
171 <p class="p2"><br></p>
172 <p class="p5"><span class="s4"><a href="Oscillators/Saw.html">Saw</a></span></p>
173 <p class="p3">arguments:<span class="Apple-converted-space">  </span>frequency, mul, add</p>
174 <p class="p2"><br></p>
175 <p class="p4">{ <span class="s3">Saw</span>.ar(<span class="s3">XLine</span>.kr(20000,200,6),0.2) }.scope(1);</p>
176 <p class="p4">{ <span class="s3">Saw</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0.2) }.scope(1); <span class="s6">// no aliasing</span></p>
177 <p class="p2"><br></p>
178 <p class="p5"><span class="s4"><a href="Oscillators/Pulse.html">Pulse</a></span></p>
179 <p class="p3">arguments:<span class="Apple-converted-space">  </span>frequency, width, mul, add</p>
180 <p class="p2"><br></p>
181 <p class="p4">{ <span class="s3">Pulse</span>.ar(<span class="s3">XLine</span>.kr(20000,200,6),0.3,0.2) }.scope(1);</p>
182 <p class="p4">{ <span class="s3">Pulse</span>.ar(<span class="s3">XLine</span>.kr(100,15000,6),0.3,0.2) }.scope(1); <span class="s6">// no aliasing</span></p>
183 <p class="p7"><br></p>
184 <p class="p6">// modulate pulse width</p>
185 <p class="p4">{ <span class="s3">Pulse</span>.ar(200, <span class="s3">Line</span>.kr(0.01,0.99,8), 0.2) }.scope(1);</p>
186 <p class="p7"><br></p>
187 <p class="p6">// two band limited square waves thru a resonant low pass filter</p>
188 <p class="p4">{ <span class="s3">RLPF</span>.ar(<span class="s3">Pulse</span>.ar([100,250],0.5,0.1), <span class="s3">XLine</span>.kr(8000,400,5), 0.05) }.scope(1);</p>
189 <p class="p8"><br></p>
190 <p class="p3"><span class="s7"><a href="Oscillators/Klang.html">Klang</a></span> - sine oscillator bank</p>
191 <p class="p3">arguments:<span class="Apple-converted-space">  </span>`[ frequencies, amplitudes, phases ], mul, add</p>
192 <p class="p8"><br></p>
193 <p class="p4">{ <span class="s3">Klang</span>.ar(`[ [800, 1000, 1200],[0.3, 0.3, 0.3],[pi,pi,pi]], 1, 0) * 0.4}.scope(1);</p>
194 <p class="p7"><br></p>
195 <p class="p4">{ <span class="s3">Klang</span>.ar(`[ {exprand(400, 2000)}.dup(16), <span class="s3">nil</span>, <span class="s3">nil</span> ], 1, 0) * 0.04 }.scope(1);</p>
196 <p class="p8"><br></p>
197 <p class="p8"><br></p>
198 <p class="p3"><b>Table Oscillators</b></p>
199 <p class="p2"><br></p>
200 <p class="p3">Osc, COsc, VOsc, VOsc3</p>
201 <p class="p3">Use a buffer allocated on the server.</p>
202 <p class="p2"><br></p>
203 <p class="p5"><span class="s4"><a href="Oscillators/Osc.html">Osc</a></span></p>
204 <p class="p3">arguments: buffer number, frequency, phase, mul, add.</p>
205 <p class="p2"><br></p>
206 <p class="p4">(</p>
207 <p class="p4">b = <span class="s3">Buffer</span>.alloc(s, 2048, 1, bufnum: 80);</p>
208 <p class="p4">b.sine1(1.0/(1..6), <span class="s3">true</span>, <span class="s3">true</span>, <span class="s3">true</span>);</p>
209 <p class="p4">)</p>
210 <p class="p7"><br></p>
211 <p class="p4">{ <span class="s3">Osc</span>.ar(80, 100, 0, 0.1) }.scope(1, zoom:4);</p>
212 <p class="p7"><br></p>
213 <p class="p4">b.sine1(1.0/(1..12));</p>
214 <p class="p4">b.sine1(1.0/(1..24));</p>
215 <p class="p4">b.sine1(1.0/(1..32));</p>
216 <p class="p4">b.sine1([1.0/(1,3..12), 0].flop.flat.postln);</p>
217 <p class="p4">b.sine1([1.0/(1,3..32).squared, 0].flop.flat.postln);</p>
218 <p class="p4">b.sine1((1.dup(4) ++ 0.dup(8)).scramble.postln);</p>
219 <p class="p4">b.sine1((1.dup(4) ++ 0.dup(8)).scramble.postln);</p>
220 <p class="p4">b.sine1((1.dup(4) ++ 0.dup(8)).scramble.postln);</p>
221 <p class="p4">b.sine1((1.dup(4) ++ 0.dup(8)).scramble.postln);</p>
222 <p class="p4">b.sine1({1.0.rand2.cubed}.dup(8).round(1e-3).postln);</p>
223 <p class="p4">b.sine1({1.0.rand2.cubed}.dup(12).round(1e-3).postln);</p>
224 <p class="p4">b.sine1({1.0.rand2.cubed}.dup(16).round(1e-3).postln);</p>
225 <p class="p4">b.sine1({1.0.rand2.cubed}.dup(24).round(1e-3).postln);</p>
226 <p class="p8"><br></p>
227 <p class="p3"><span class="s7"><a href="Oscillators/COsc.html">COsc</a></span> - two oscillators, detuned</p>
228 <p class="p3">arguments: buffer number, frequency, beat frequency, mul, add.</p>
229 <p class="p8"><br></p>
230 <p class="p4">b.sine1(1.0/(1..6), <span class="s3">true</span>, <span class="s3">true</span>, <span class="s3">true</span>);</p>
231 <p class="p7"><br></p>
232 <p class="p4">{ <span class="s3">COsc</span>.ar(80, 100, 1, 0.1) }.scope(1, zoom:4);</p>
233 <p class="p6">// change buffer as above.</p>
234 <p class="p8"><br></p>
235 <p class="p8"><br></p>
236 <p class="p3"><span class="s7"><a href="Oscillators/VOsc.html">VOsc</a></span> - multiple wave table crossfade oscillators</p>
237 <p class="p3">arguments: buffer number, frequency, phase, mul, add.</p>
238 <p class="p8"><br></p>
239 <p class="p4">(</p>
240 <p class="p6">// allocate tables 80 to 87</p>
241 <p class="p4">8.do {<span class="s3">|i|</span> s.sendMsg(<span class="s8">\b_alloc</span>, 80+i, 1024); };</p>
242 <p class="p4">)</p>
243 <p class="p7"><br></p>
244 <p class="p4">(</p>
245 <p class="p6">// fill tables 80 to 87</p>
246 <p class="p4">8.do({<span class="s3">|i|</span></p>
247 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> n, a;</p>
248 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// generate array of harmonic amplitudes</p>
249 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span>n = (i+1)**2; </span>// num harmonics for each table: [1,4,9,16,25,36,49,64]</p>
250 <p class="p4"><span class="Apple-tab-span"> </span>a = {<span class="s3">|j|</span> ((n-j)/n).squared }.dup(n);</p>
251 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// fill table</p>
252 <p class="p4"><span class="Apple-tab-span"> </span>s.listSendMsg([<span class="s8">\b_gen</span>, 80+i, <span class="s8">\sine1</span>, 7] ++ a);</p>
253 <p class="p4">});</p>
254 <p class="p4">)</p>
255 <p class="p7"><br></p>
256 <p class="p4">{ <span class="s3">VOsc</span>.ar(<span class="s3">MouseX</span>.kr(80,87), 120, 0, 0.3) }.scope(1, zoom:4);</p>
257 <p class="p7"><br></p>
258 <p class="p4">(</p>
259 <p class="p6">// allocate and fill tables 80 to 87</p>
260 <p class="p4">8.do({<span class="s3">|i|</span></p>
261 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// generate array of harmonic amplitudes</p>
262 <p class="p4"><span class="Apple-tab-span"> </span>a = {1.0.rand2.cubed }.dup((i+1)*4);</p>
263 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// fill table</p>
264 <p class="p4"><span class="Apple-tab-span"> </span>s.listSendMsg([<span class="s8">\b_gen</span>, 80+i, <span class="s8">\sine1</span>, 7] ++ a);</p>
265 <p class="p4">});</p>
266 <p class="p4">)</p>
267 <p class="p8"><br></p>
268 <p class="p3"><span class="s7"><a href="Oscillators/VOsc3.html">VOsc3</a></span> - three VOscs summed.</p>
269 <p class="p3">arguments: buffer number, freq1, freq2, freq3, beat frequency, mul, add.</p>
270 <p class="p8"><br></p>
271 <p class="p6">// chorusing</p>
272 <p class="p4">{ <span class="s3">VOsc3</span>.ar(<span class="s3">MouseX</span>.kr(80,87), 120, 121.04, 119.37, 0.2) }.scope(1, zoom:4);</p>
273 <p class="p7"><br></p>
274 <p class="p6">// chords</p>
275 <p class="p4">{ <span class="s3">VOsc3</span>.ar(<span class="s3">MouseX</span>.kr(80,87), 120, 151.13, 179.42, 0.2) }.scope(1, zoom:4);</p>
276 <p class="p8"><br></p>
277 <p class="p3"><b>Aperiodic Sources: Noise.</b></p>
278 <p class="p8"><br></p>
279 <p class="p8"><br></p>
280 <p class="p3">LF "Low Frequency" Noise Generators.</p>
281 <p class="p8"><br></p>
282 <p class="p5"><span class="s4"><a href="Noise/LFNoise0.html">LFNoise0</a></span><span class="s5">, <a href="Noise/LFNoise1.html"><span class="s4">LFNoise1</span></a>, <a href="Noise/LFNoise2.html"><span class="s4">LFNoise2</span></a>, <a href="Noise/LFClipNoise.html"><span class="s4">LFClipNoise</span></a></span></p>
283 <p class="p3">arguments: frequency, mul, add</p>
284 <p class="p2"><br></p>
285 <p class="p4">{ <span class="s3">LFClipNoise</span>.ar(<span class="s3">MouseX</span>.kr(200, 10000, 1), 0.125) }.scope(1);</p>
286 <p class="p4">{ <span class="s3">LFNoise0</span>.ar(<span class="s3">MouseX</span>.kr(200, 10000, 1), 0.25) }.scope(1);</p>
287 <p class="p4">{ <span class="s3">LFNoise1</span>.ar(<span class="s3">MouseX</span>.kr(200, 10000, 1), 0.25) }.scope(1);</p>
288 <p class="p4">{ <span class="s3">LFNoise2</span>.ar(<span class="s3">MouseX</span>.kr(200, 10000, 1), 0.25) }.scope(1);</p>
289 <p class="p7"><br></p>
290 <p class="p6">// used as controls</p>
291 <p class="p4">{ <span class="s3">LFPar</span>.ar(<span class="s3">LFClipNoise</span>.kr(<span class="s3">MouseX</span>.kr(0.5, 64, 1), 200, 400), 0, 0.2) }.scope(1, zoom:8);</p>
292 <p class="p4">{ <span class="s3">LFPar</span>.ar(<span class="s3">LFNoise0</span>.kr(<span class="s3">MouseX</span>.kr(0.5, 64, 1), 200, 400), 0, 0.2) }.scope(1, zoom:8);</p>
293 <p class="p4">{ <span class="s3">LFPar</span>.ar(<span class="s3">LFNoise1</span>.kr(<span class="s3">MouseX</span>.kr(0.5, 64, 1), 200, 400), 0, 0.2) }.scope(1, zoom:8);</p>
294 <p class="p4">{ <span class="s3">LFPar</span>.ar(<span class="s3">LFNoise2</span>.kr(<span class="s3">MouseX</span>.kr(0.5, 64, 1), 200, 400), 0, 0.2) }.scope(1, zoom:8);</p>
295 <p class="p8"><br></p>
296 <p class="p8"><br></p>
297 <p class="p3">Broad Spectrum Noise Generators</p>
298 <p class="p2"><br></p>
299 <p class="p5"><span class="s4"><a href="Noise/ClipNoise.html">ClipNoise</a></span><span class="s5">, <a href="Noise/WhiteNoise.html"><span class="s4">WhiteNoise</span></a>, <a href="Noise/PinkNoise.html"><span class="s4">PinkNoise</span></a>, <a href="Noise/BrownNoise.html"><span class="s4">BrownNoise</span></a>, <a href="Noise/GrayNoise.html"><span class="s4">GrayNoise</span></a></span></p>
300 <p class="p3">arguments: mul, add</p>
301 <p class="p2"><br></p>
302 <p class="p4">{ <span class="s3">ClipNoise</span>.ar(0.2) }.scope(1);</p>
303 <p class="p4">{ <span class="s3">WhiteNoise</span>.ar(0.2) }.scope(1);</p>
304 <p class="p4">{ <span class="s3">PinkNoise</span>.ar(0.4) }.scope(1);</p>
305 <p class="p4">{ <span class="s3">BrownNoise</span>.ar(0.2) }.scope(1);</p>
306 <p class="p4">{ <span class="s3">GrayNoise</span>.ar(0.2) }.scope(1);</p>
307 <p class="p2"><br></p>
308 <p class="p3">Impulse Noise Generators</p>
309 <p class="p2"><br></p>
310 <p class="p5"><span class="s4"><a href="Noise/Dust.html">Dust</a></span><span class="s5">, <a href="Noise/Dust2.html"><span class="s4">Dust2</span></a></span></p>
311 <p class="p3">arguments: density, mul, add</p>
312 <p class="p2"><br></p>
313 <p class="p4">{ <span class="s3">Dust</span>.ar(<span class="s3">MouseX</span>.kr(1,10000,1), 0.4) }.scope(1, zoom:4);</p>
314 <p class="p4">{ <span class="s3">Dust2</span>.ar(<span class="s3">MouseX</span>.kr(1,10000,1), 0.4) }.scope(1, zoom:4);</p>
315 <p class="p7"><br></p>
316 <p class="p7"><br></p>
317 <p class="p3">Chaotic Noise Generators</p>
318 <p class="p2"><br></p>
319 <p class="p5"><span class="s4"><a href="Noise/Crackle.html">Crackle</a></span></p>
320 <p class="p3">arguments: chaosParam, mul, add</p>
321 <p class="p7"><br></p>
322 <p class="p4">{ <span class="s3">Crackle</span>.ar(<span class="s3">MouseX</span>.kr(1,2), 0.5) }.scope(1);</p>
323 <p class="p2"><br></p>
324 <p class="p3"><b>Filters</b></p>
325 <p class="p7"><br></p>
326 <p class="p3">Low Pass, High Pass</p>
327 <p class="p2"><br></p>
328 <p class="p3"><span class="s7"><a href="Filters/LPF.html">LPF</a></span>, <a href="Filters/HPF.html"><span class="s9">HPF</span></a> - 12 dB / octave</p>
329 <p class="p3">arguments: in, freq, mul, add</p>
330 <p class="p7"><br></p>
331 <p class="p4">{ <span class="s3">LPF</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2) }.scope(1);</p>
332 <p class="p4">{ <span class="s3">HPF</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2) }.scope(1);</p>
333 <p class="p4">{ <span class="s3">LPF</span>.ar(<span class="s3">Saw</span>.ar(100), <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2) }.scope(1);</p>
334 <p class="p4">{ <span class="s3">HPF</span>.ar(<span class="s3">Saw</span>.ar(100), <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2) }.scope(1);</p>
335 <p class="p7"><br></p>
336 <p class="p3">Band Pass, Band Cut</p>
337 <p class="p2"><br></p>
338 <p class="p3"><span class="s7"><a href="Filters/BPF.html">BPF</a></span>, <a href="Filters/BRF.html"><span class="s9">BRF</span></a> - 12 dB / octave</p>
339 <p class="p3">arguments: in, freq, rq, mul, add</p>
340 <p class="p3">rq is the reciprocal of the Q of the filter,</p>
341 <p class="p3">or in other words: the bandwidth in Hertz = rq * freq.</p>
342 <p class="p2"><br></p>
343 <p class="p4">{ <span class="s3">BPF</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.4, 0.4) }.scope(1);</p>
344 <p class="p4">{ <span class="s3">BRF</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.4, 0.2) }.scope(1);</p>
345 <p class="p4">{ <span class="s3">BPF</span>.ar(<span class="s3">Saw</span>.ar(100), <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.4, 0.4) }.scope(1);</p>
346 <p class="p4">{ <span class="s3">BRF</span>.ar(<span class="s3">Saw</span>.ar(100), <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.4, 0.2) }.scope(1);</p>
347 <p class="p7"><br></p>
348 <p class="p6">// modulating the bandwidth</p>
349 <p class="p4">{ <span class="s3">BPF</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">3000</span>, MouseX.kr(0.01,0.7,1), 0.4) }.scope(1);</p>
350 <p class="p7"><br></p>
351 <p class="p3">Resonant Low Pass, High Pass, Band Pass</p>
352 <p class="p7"><br></p>
353 <p class="p3"><span class="s7"><a href="Filters/RLPF.html">RLPF</a></span>, <a href="Filters/RHPF.html"><span class="s9">RHPF</span></a> - 12 dB / octave</p>
354 <p class="p3">arguments: in, freq, rq, mul, add</p>
355 <p class="p7"><br></p>
356 <p class="p4">{ <span class="s3">RLPF</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2, 0.2) }.scope(1);</p>
357 <p class="p4">{ <span class="s3">RHPF</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2, 0.2) }.scope(1);</p>
358 <p class="p4">{ <span class="s3">RLPF</span>.ar(<span class="s3">Saw</span>.ar(100), <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2, 0.2) }.scope(1);</p>
359 <p class="p4">{ <span class="s3">RHPF</span>.ar(<span class="s3">Saw</span>.ar(100), <span class="s3">MouseX</span>.kr(1e2,2e4,1), 0.2, 0.2) }.scope(1);</p>
360 <p class="p7"><br></p>
361 <p class="p3"><span class="s7"><a href="Filters/Resonz.html">Resonz</a></span> - resonant band pass filter with uniform amplitude</p>
362 <p class="p3">arguments: in, freq, rq, mul, add</p>
363 <p class="p7"><br></p>
364 <p class="p6">// modulate frequency</p>
365 <p class="p4">{ <span class="s3">Resonz</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.5), <span class="s3">XLine</span>.kr(1000,8000,10), 0.05) }.scope(1);</p>
366 <p class="p7"><br></p>
367 <p class="p6">// modulate bandwidth</p>
368 <p class="p4">{ <span class="s3">Resonz</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.5), 2000, <span class="s3">XLine</span>.kr(1, 0.001, 8)) }.scope(1);</p>
369 <p class="p7"><br></p>
370 <p class="p6">// modulate bandwidth opposite direction</p>
371 <p class="p4">{ <span class="s3">Resonz</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.5), 2000, <span class="s3">XLine</span>.kr(0.001, 1, 8)) }.scope(1);</p>
372 <p class="p7"><br></p>
373 <p class="p3"><span class="s7"><a href="Filters/Ringz.html">Ringz</a></span> - ringing filter.</p>
374 <p class="p3">Internally it is the same as Resonz but the bandwidth is expressed as a ring time.</p>
375 <p class="p3">arguments: in, frequency, ring time, mul, add</p>
376 <p class="p7"><br></p>
377 <p class="p4">{ <span class="s3">Ringz</span>.ar(<span class="s3">Dust</span>.ar(3, 0.3), 2000, 2) }.scope(1, zoom:4);</p>
378 <p class="p7"><br></p>
379 <p class="p4">{ <span class="s3">Ringz</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.005), 2000, 0.5) }.scope(1);</p>
380 <p class="p7"><br></p>
381 <p class="p6">// modulate frequency</p>
382 <p class="p4">{ <span class="s3">Ringz</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.005), <span class="s3">XLine</span>.kr(100,3000,10), 0.5) }.scope(1, zoom:4);</p>
383 <p class="p7"><br></p>
384 <p class="p4">{ <span class="s3">Ringz</span>.ar(<span class="s3">Impulse</span>.ar(6, 0, 0.3),<span class="Apple-converted-space">  </span><span class="s3">XLine</span>.kr(100,3000,10), 0.5) }.scope(1, zoom:4);</p>
385 <p class="p7"><br></p>
386 <p class="p6">// modulate ring time</p>
387 <p class="p4">{ <span class="s3">Ringz</span>.ar(<span class="s3">Impulse</span>.ar(6, 0, 0.3), 2000, <span class="s3">XLine</span>.kr(0.04, 4, 8)) }.scope(1, zoom:4);</p>
388 <p class="p7"><br></p>
389 <p class="p7"><br></p>
390 <p class="p3">Simpler Filters</p>
391 <p class="p3">6 dB / octave</p>
392 <p class="p7"><br></p>
393 <p class="p4">{ <span class="s3">OnePole</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.5), <span class="s3">MouseX</span>.kr(-0.99, 0.99)) }.scope(1);</p>
394 <p class="p4">{ <span class="s3">OneZero</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.5), <span class="s3">MouseX</span>.kr(-0.49, 0.49)) }.scope(1);</p>
395 <p class="p7"><br></p>
396 <p class="p3">NonLinear Filters</p>
397 <p class="p5"><span class="s4"><a href="Filters/Median.html">Median</a></span><span class="s5">, <a href="Synth control/Slew.html"><span class="s10">Slew</span></a></span></p>
398 <p class="p2"><br></p>
399 <p class="p6">// a signal with impulse noise.</p>
400 <p class="p4">{ <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">Dust2</span>.ar(100, 0.9) }.scope(1);</p>
401 <p class="p6">// after applying median filter</p>
402 <p class="p4">{ <span class="s3">Median</span>.ar(3, <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">Dust2</span>.ar(100, 0.9)) }.scope(1);</p>
403 <p class="p2"><br></p>
404 <p class="p6">// a signal with impulse noise.</p>
405 <p class="p4">{ <span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">Dust2</span>.ar(100, 0.9) }.scope(1);</p>
406 <p class="p6">// after applying slew rate limiter</p>
407 <p class="p4">{ <span class="s3">Slew</span>.ar(<span class="s3">Saw</span>.ar(500, 0.1) + <span class="s3">Dust2</span>.ar(100, 0.9),1000,1000) }.scope(1);</p>
408 <p class="p2"><br></p>
409 <p class="p7"><br></p>
410 <p class="p3">Formant Filter<span class="Apple-converted-space"> </span></p>
411 <p class="p3"><span class="s7"><a href="Filters/Formlet.html">Formlet</a></span> - A filter whose impulse response is similar to a FOF grain.</p>
412 <p class="p7"><br></p>
413 <p class="p4">{ <span class="s3">Formlet</span>.ar(<span class="s3">Impulse</span>.ar(<span class="s3">MouseX</span>.kr(2,300,1), 0, 0.4), 800, 0.01, 0.1) }.scope(1, zoom:4);</p>
414 <p class="p7"><br></p>
415 <p class="p3">Klank - resonant filter bank</p>
416 <p class="p3">arguments:<span class="Apple-converted-space">  </span>`[ frequencies, amplitudes, ring times ], mul, add</p>
417 <p class="p8"><br></p>
418 <p class="p4">{ <span class="s3">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s3">nil</span>, [1, 1, 1, 1]], <span class="s3">Impulse</span>.ar(2, 0, 0.1)) }.play;</p>
419 <p class="p7"><br></p>
420 <p class="p4">{ <span class="s3">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s3">nil</span>, [1, 1, 1, 1]], <span class="s3">Dust</span>.ar(8, 0.1)) }.play;</p>
421 <p class="p7"><br></p>
422 <p class="p4">{ <span class="s3">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s3">nil</span>, [1, 1, 1, 1]], <span class="s3">PinkNoise</span>.ar(0.007)) }.play;</p>
423 <p class="p7"><br></p>
424 <p class="p4">{ <span class="s3">Klank</span>.ar(`[ {exprand(200, 4000)}.dup(12), <span class="s3">nil</span>, <span class="s3">nil</span> ], <span class="s3">PinkNoise</span>.ar(0.007)) }.scope(1);</p>
425 <p class="p8"><br></p>
426 <p class="p4">{ <span class="s3">Klank</span>.ar(`[ (1..13)*200, <span class="s3">1/</span>(1..13), <span class="s3">nil</span> ], <span class="s3">PinkNoise</span>.ar(0.01)) }.scope(1);</p>
427 <p class="p7"><br></p>
428 <p class="p4">{ <span class="s3">Klank</span>.ar(`[ (1,3..13)*200, <span class="s3">1/</span>(1,3..13), <span class="s3">nil</span> ], <span class="s3">PinkNoise</span>.ar(0.01)) }.scope(1);</p>
429 <p class="p8"><br></p>
430 <p class="p8"><br></p>
431 <p class="p3"><b>Distortion</b></p>
432 <p class="p2"><br></p>
433 <p class="p3">abs, max, squared, cubed</p>
434 <p class="p8"><br></p>
435 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">0.2</span>) }.scope(1);</p>
436 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">0.2</span>).abs }.scope(1);</p>
437 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">0.2</span>).max(0) }.scope(1);</p>
438 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0).squared * 0.2 }.scope(1);</p>
439 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0).cubed * 0.2 }.scope(1);</p>
440 <p class="p7"><br></p>
441 <p class="p3">distort, softclip, clip2, fold2, wrap2,<span class="Apple-converted-space"> </span></p>
442 <p class="p7"><br></p>
443 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">MouseX</span>.kr(0.1,80,1)).distort * 0.2 }.scope(1);</p>
444 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">MouseX</span>.kr(0.1,80,1)).softclip * 0.2 }.scope(1);</p>
445 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">MouseX</span>.kr(0.1,80,1)).clip2(1) * 0.2 }.scope(1);</p>
446 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">MouseX</span>.kr(0.1,80,1)).fold2(1) * 0.2 }.scope(1);</p>
447 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">MouseX</span>.kr(0.1,80,1)).wrap2(1) * 0.2 }.scope(1);</p>
448 <p class="p4">{ <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">MouseX</span>.kr(0.1,80,1)).wrap2(1) * 0.2 }.scope(1);</p>
449 <p class="p8"><br></p>
450 <p class="p3">scaleneg</p>
451 <p class="p8"><br></p>
452 <p class="p4">{ <span class="s3">SinOsc</span>.ar(200, 0, <span class="s3">0.2</span>).scaleneg(<span class="s3">MouseX</span>.kr(-1,1)) }.scope(1);</p>
453 <p class="p7"><br></p>
454 <p class="p3">waveshaping by phase modulating a 0 Hz sine oscillator</p>
455 <p class="p3">(currently there is a limit of 8pi)</p>
456 <p class="p7"><br></p>
457 <p class="p4">(</p>
458 <p class="p4">{<span class="Apple-converted-space"> </span></p>
459 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in;</p>
460 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">SinOsc</span>.ar(300, 0, <span class="s3">MouseX</span>.kr(0.1,8pi,1));</p>
461 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span><span class="s3">SinOsc</span><span class="s5">.ar(0, in, 0.2); </span>// 0 Hz sine oscillator</p>
462 <p class="p4">}.scope(1);</p>
463 <p class="p4">)</p>
464 <p class="p7"><br></p>
465 <p class="p5"><span class="s4"><a href="Oscillators/Shaper.html">Shaper</a></span><span class="s5"><span class="Apple-converted-space"> </span></span></p>
466 <p class="p3">input is used to look up a value in a table.</p>
467 <p class="p3">Chebyshev polynomials are typically used to fill the table.</p>
468 <p class="p2"><br></p>
469 <p class="p9"><span class="s11"><img src="attachments/Tour_of_UGens/chebyshevpolynomials.png" alt="attachments/Tour_of_UGens/chebyshevpolynomials.png"></span></p>
470 <p class="p7"><br></p>
471 <p class="p4">s.sendMsg(<span class="s8">\b_alloc</span>, 80, 1024); <span class="s6">// allocate table</span></p>
472 <p class="p6">// fill with chebyshevs</p>
473 <p class="p4">s.listSendMsg([<span class="s8">\b_gen</span>, 80, <span class="s8">\cheby</span>, 7] ++ {1.0.rand2.squared}.dup(6));</p>
474 <p class="p10"><br></p>
475 <p class="p4">{ <span class="s3">Shaper</span>.ar(80, <span class="s3">SinOsc</span>.ar(600, 0, <span class="s3">MouseX</span>.kr(0,1))) * 0.3; }.scope(1);</p>
476 <p class="p10"><br></p>
477 <p class="p4">s.listSendMsg([<span class="s8">\b_gen</span>, 80, <span class="s8">\cheby</span>, 7] ++ {1.0.rand2.squared}.dup(6));</p>
478 <p class="p4">s.listSendMsg([<span class="s8">\b_gen</span>, 80, <span class="s8">\cheby</span>, 7] ++ {1.0.rand2.squared}.dup(6));</p>
479 <p class="p7"><br></p>
480 <p class="p3"><b>Panning</b></p>
481 <p class="p2"><br></p>
482 <p class="p4">(</p>
483 <p class="p4">s = <span class="s3">Server</span>.internal;</p>
484 <p class="p4"><span class="s3">Server</span>.default = s;</p>
485 <p class="p4">s.quit;</p>
486 <p class="p4">s.options.numOutputBusChannels = 8;</p>
487 <p class="p4">s.options.numInputBusChannels = 8;</p>
488 <p class="p4">s.boot;</p>
489 <p class="p4">)</p>
490 <p class="p2"><br></p>
491 <p class="p3"><span class="s7"><a href="Multichannel/Panners/Pan2.html">Pan2</a></span> - equal power stereo pan a mono source</p>
492 <p class="p3">arguments: in, pan position, level</p>
493 <p class="p3">pan controls typically range from -1 to +1</p>
494 <p class="p2"><br></p>
495 <p class="p4">{ <span class="s3">Pan2</span>.ar(<span class="s3">BrownNoise</span>.ar, <span class="s3">MouseX</span>.kr(-1,1), 0.3) }.scope(2);</p>
496 <p class="p4">{ <span class="s3">Pan2</span>.ar(<span class="s3">BrownNoise</span>.ar, <span class="s3">SinOsc</span>.kr(0.2), 0.3) }.scope(2);</p>
497 <p class="p7"><br></p>
498 <p class="p3"><span class="s7"><a href="Multichannel/Panners/LinPan2.html">LinPan2</a></span> - linear pan a mono source (not equal power)</p>
499 <p class="p3">arguments: in, pan position, level</p>
500 <p class="p7"><br></p>
501 <p class="p4">{ <span class="s3">LinPan2</span>.ar(<span class="s3">BrownNoise</span>.ar, <span class="s3">MouseX</span>.kr(-1,1), 0.3) }.scope(2);</p>
502 <p class="p4">{ <span class="s3">LinPan2</span>.ar(<span class="s3">BrownNoise</span>.ar, <span class="s3">SinOsc</span>.kr(0.2), 0.3) }.scope(2);</p>
503 <p class="p7"><br></p>
504 <p class="p3">Balance2 - balance a stereo source</p>
505 <p class="p3">arguments: left in, right in, pan position, level</p>
506 <p class="p7"><br></p>
507 <p class="p4">{ <span class="s3">Balance2</span>.ar(<span class="s3">BrownNoise</span>.ar, <span class="s3">BrownNoise</span>.ar, <span class="s3">MouseX</span>.kr(-1,1), 0.3) }.scope(2);</p>
508 <p class="p7"><br></p>
509 <p class="p3"><span class="s7"><a href="Multichannel/Panners/Pan4.html">Pan4</a></span> - equal power quad panner</p>
510 <p class="p7"><br></p>
511 <p class="p4">{ <span class="s3">Pan4</span>.ar(<span class="s3">BrownNoise</span>.ar, <span class="s3">MouseX</span>.kr(-1,1), <span class="s3">MouseY</span>.kr(1,-1), 0.3) }.scope(4);</p>
512 <p class="p7"><br></p>
513 <p class="p3"><span class="s7"><a href="Multichannel/Panners/PanAz.html">PanAz</a></span> - azimuth panner to any number of channels</p>
514 <p class="p3">arguments: num channels, in, pan position, level, width</p>
515 <p class="p7"><br></p>
516 <p class="p4">{ <span class="s3">PanAz</span>.ar(5, <span class="s3">BrownNoise</span>.ar, <span class="s3">MouseX</span>.kr(-1,1), 0.3, 2) }.scope(5);</p>
517 <p class="p7"><br></p>
518 <p class="p6">// change width to 3</p>
519 <p class="p4">{ <span class="s3">PanAz</span>.ar(5, <span class="s3">BrownNoise</span>.ar, <span class="s3">MouseX</span>.kr(-1,1), 0.3, 3) }.scope(5);</p>
520 <p class="p7"><br></p>
521 <p class="p7"><br></p>
522 <p class="p3"><span class="s7"><a href="Multichannel/Panners/XFade2.html">XFade2</a></span> - equal power cross fade between two inputs</p>
523 <p class="p3">arguments: in1, in2, crossfade, level</p>
524 <p class="p7"><br></p>
525 <p class="p4">{ <span class="s3">XFade2</span>.ar(<span class="s3">BrownNoise</span>.ar, SinOsc.ar(500), <span class="s3">MouseX</span>.kr(-1,1), 0.3) }.scope(1);</p>
526 <p class="p7"><br></p>
527 <p class="p10"><br></p>
528 <p class="p3"><span class="s7"><a href="Multichannel/Panners/PanB2.html">PanB2</a></span> and <a href="Multichannel/Panners/DecodeB2.html"><span class="s9">DecodeB2</span></a> - 2D ambisonics panner and decoder</p>
529 <p class="p7"><br></p>
530 <p class="p4">(</p>
531 <p class="p4">{</p>
532 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> w, x, y, p, lf, rf, rr, lr;</p>
533 <p class="p7"><span class="Apple-tab-span"> </span></p>
534 <p class="p4"><span class="Apple-tab-span"> </span>p = <span class="s3">BrownNoise</span>.ar; <span class="s6">// source</span></p>
535 <p class="p7"><span class="Apple-tab-span"> </span></p>
536 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// B-format encode</p>
537 <p class="p4"><span class="Apple-tab-span"> </span>#w, x, y = <span class="s3">PanB2</span>.ar(p, <span class="s3">MouseX</span>.kr(-1,1), 0.3);<span class="Apple-converted-space"> </span></p>
538 <p class="p7"><span class="Apple-tab-span"> </span></p>
539 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// B-format decode to quad. outputs in clockwise order</p>
540 <p class="p4"><span class="Apple-tab-span"> </span>#lf, rf, rr, lr = <span class="s3">DecodeB2</span>.ar(4, w, x, y);</p>
541 <p class="p7"><span class="Apple-tab-span"> </span></p>
542 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span>[lf, rf, lr, rr] </span>// reorder to my speaker arrangement: Lf Rf Lr Rr</p>
543 <p class="p4">}.scope(4);</p>
544 <p class="p11">)</p>
545 <p class="p8"><br></p>
546 <p class="p3"><span class="s7"><a href="Multichannel/Panners/Rotate2.html">Rotate2</a></span> - rotate a sound field of ambisonic or even stereo sound.</p>
547 <p class="p7"><br></p>
548 <p class="p4">(</p>
549 <p class="p4">{</p>
550 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// rotation of stereo sound via mouse<span class="Apple-converted-space"> </span></p>
551 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> x, y;</p>
552 <p class="p4"><span class="Apple-tab-span"> </span>x = <span class="s3">Mix</span>.fill(4, { <span class="s3">LFSaw</span>.ar(200 + 2.0.rand2, 0, 0.1) }); <span class="s6">// left in</span></p>
553 <p class="p4"><span class="Apple-tab-span"> </span>y = <span class="s3">WhiteNoise</span>.ar * <span class="s3">LFPulse</span>.kr(3,0,0.7,0.2); <span class="s6">// right in</span></p>
554 <p class="p4"><span class="Apple-tab-span"> </span>#x, y = <span class="s3">Rotate2</span>.ar(x, y, <span class="s3">MouseX</span>.kr(0,2));</p>
555 <p class="p4"><span class="Apple-tab-span"> </span>[x,y]</p>
556 <p class="p4">}.scope(2);</p>
557 <p class="p4">)</p>
558 <p class="p7"><br></p>
559 <p class="p3"><b>Reverbs</b></p>
560 <p class="p5"><span class="s4"><a href="Reverbs/FreeVerb.html">FreeVerb</a></span><span class="s5"><span class="Apple-converted-space"> </span></span></p>
561 <p class="p2"><br></p>
562 <p class="p4">(</p>
563 <p class="p4">{</p>
564 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// play with the room size</p>
565 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> x;</p>
566 <p class="p4"><span class="Apple-tab-span"> </span>x = <span class="s3">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s3">nil</span>, [1, 1, 1, 1]], <span class="s3">Dust</span>.ar(2, 0.1));</p>
567 <p class="p4"><span class="Apple-tab-span"> </span>x = Pan2.ar(x, -0.2);</p>
568 <p class="p4"><span class="Apple-tab-span"> </span>x = [x[0], DelayC.ar(x[1], 0.01, 0.01)]; // de-correlate</p>
569 <p class="p4"><span class="Apple-tab-span"> </span>FreeVerb.ar(x, 0.75, 0.9, 0.4);</p>
570 <p class="p4">}.scope;</p>
571 <p class="p3">)</p>
572 <p class="p2"><br></p>
573 <p class="p5"><span class="s4"><a href="Reverbs/GVerb.html">GVerb</a></span></p>
574 <p class="p2"><br></p>
575 <p class="p4">(</p>
576 <p class="p4">{</p>
577 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// play with the room size</p>
578 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> x;</p>
579 <p class="p4"><span class="Apple-tab-span"> </span>x = <span class="s3">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s3">nil</span>, [1, 1, 1, 1]], <span class="s3">Dust</span>.ar(2, 0.1));</p>
580 <p class="p4"><span class="Apple-tab-span"> </span>GVerb.ar(x, 105, 5, 0.7, 0.8, 60, 0.1, 0.5, 0.4) + x;</p>
581 <p class="p4">}.scope;</p>
582 <p class="p3">)</p>
583 <p class="p2"><br></p>
584 <p class="p3"><b>Delays and Buffer UGens</b></p>
585 <p class="p2"><br></p>
586 <p class="p5"><span class="s4"><a href="Delays/DelayN.html">DelayN</a></span><span class="s5">, <a href="Delays/DelayL.html"><span class="s4">DelayL</span></a>, <a href="Delays/DelayC.html"><span class="s4">DelayC</span></a></span></p>
587 <p class="p3">simple delays</p>
588 <p class="p3">N - no interpolation</p>
589 <p class="p3">L - linear interpolation</p>
590 <p class="p3">C - cubic interpolation</p>
591 <p class="p3">arguments: in, maximum delay time, current delay time, mul, add</p>
592 <p class="p2"><br></p>
593 <p class="p4">(</p>
594 <p class="p6">// Dust randomly triggers Decay to create an exponential<span class="Apple-converted-space"> </span></p>
595 <p class="p6">// decay envelope for the WhiteNoise input source</p>
596 <p class="p4">{</p>
597 <p class="p4">z = <span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(1,0.5), 0.3, <span class="s3">WhiteNoise</span>.ar);</p>
598 <p class="p6"><span class="s3">DelayN</span>.ar(z, 0.1, 0.1, 1, z); // input is mixed with delay via the add input</p>
599 <p class="p4">}.scope(1, zoom: 4)</p>
600 <p class="p4">)</p>
601 <p class="p2"><br></p>
602 <p class="p4">(</p>
603 <p class="p4">{</p>
604 <p class="p4">z = <span class="s3">Decay</span>.ar(<span class="s3">Impulse</span>.ar(2,0,0.4), 0.3, <span class="s3">WhiteNoise</span>.ar);</p>
605 <p class="p6"><span class="s3">DelayL</span>.ar(z, 0.3, MouseX.kr(0,0.3), 1, z); // input is mixed with delay via the add input</p>
606 <p class="p4">}.scope(1, zoom: 4)</p>
607 <p class="p4">)</p>
608 <p class="p7"><br></p>
609 <p class="p5"><span class="s4"><a href="Delays/CombN.html">CombN</a></span><span class="s5">, <a href="Delays/CombL.html"><span class="s4">CombL</span></a>, <a href="Delays/CombC.html"><span class="s4">CombC</span></a></span></p>
610 <p class="p3">feedback delays</p>
611 <p class="p3">arguments: in, maximum delay time, current delay time, echo decay time, mul, add</p>
612 <p class="p2"><br></p>
613 <p class="p12"><br></p>
614 <p class="p6">// used as an echo.<span class="Apple-converted-space"> </span></p>
615 <p class="p4">{ <span class="s3">CombN</span>.ar(<span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(1,0.5), 0.2, <span class="s3">WhiteNoise</span>.ar), 0.2, 0.2, 3) }.scope(1, zoom:4);</p>
616 <p class="p7"><br></p>
617 <p class="p6">// Comb used as a resonator. The resonant fundamental is equal to<span class="Apple-converted-space"> </span></p>
618 <p class="p6">// reciprocal of the delay time.</p>
619 <p class="p4">{ <span class="s3">CombN</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.02), 0.01, <span class="s3">XLine</span>.kr(0.0001, 0.01, 20), 0.2) }.scope(1);</p>
620 <p class="p7"><br></p>
621 <p class="p4">{ <span class="s3">CombL</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.02), 0.01, <span class="s3">XLine</span>.kr(0.0001, 0.01, 20), 0.2) }.scope(1);</p>
622 <p class="p7"><br></p>
623 <p class="p4">{ <span class="s3">CombC</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.02), 0.01, <span class="s3">XLine</span>.kr(0.0001, 0.01, 20), 0.2) }.scope(1);</p>
624 <p class="p7"><br></p>
625 <p class="p6">// with negative feedback:</p>
626 <p class="p4">{ <span class="s3">CombN</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.02), 0.01, <span class="s3">XLine</span>.kr(0.0001, 0.01, 20), -0.2) }.scope(1);</p>
627 <p class="p7"><br></p>
628 <p class="p4">{ <span class="s3">CombL</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.02), 0.01, <span class="s3">XLine</span>.kr(0.0001, 0.01, 20), -0.2) }.scope(1);</p>
629 <p class="p7"><br></p>
630 <p class="p4">{ <span class="s3">CombC</span>.ar(<span class="s3">WhiteNoise</span>.ar(0.02), 0.01, <span class="s3">XLine</span>.kr(0.0001, 0.01, 20), -0.2) }.scope(1);</p>
631 <p class="p2"><br></p>
632 <p class="p4">{ <span class="s3">CombC</span>.ar(<span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(1,0.1), 0.2, <span class="s3">WhiteNoise</span>.ar), 1/100, 1/100, 3) }.play;</p>
633 <p class="p4">{ <span class="s3">CombC</span>.ar(<span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(1,0.1), 0.2, <span class="s3">WhiteNoise</span>.ar), 1/200, 1/200, 3) }.play;</p>
634 <p class="p4">{ <span class="s3">CombC</span>.ar(<span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(1,0.1), 0.2, <span class="s3">WhiteNoise</span>.ar), 1/300, 1/300, 3) }.play;</p>
635 <p class="p4">{ <span class="s3">CombC</span>.ar(<span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(1,0.1), 0.2, <span class="s3">WhiteNoise</span>.ar), 1/400, 1/400, 3) }.scope(1, zoom:4);</p>
636 <p class="p2"><br></p>
637 <p class="p7"><br></p>
638 <p class="p5"><span class="s4"><a href="Delays/AllpassN.html">AllpassN</a></span><span class="s5">, <a href="Delays/AllpassL.html"><span class="s4">AllpassL</span></a>, <a href="Delays/AllpassC.html"><span class="s4">AllpassC</span></a></span></p>
639 <p class="p3">allpass delay</p>
640 <p class="p3">arguments: in, maximum delay time, current delay time, echo decay time, mul, add</p>
641 <p class="p2"><br></p>
642 <p class="p4">(</p>
643 <p class="p4">{</p>
644 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> z;</p>
645 <p class="p4"><span class="Apple-tab-span"> </span>z = <span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(1,0.5), 0.1, <span class="s3">WhiteNoise</span>.ar);</p>
646 <p class="p4"><span class="Apple-tab-span"> </span>8.do { z = <span class="s3">AllpassL</span>.ar(z, 0.04, 0.04.rand, 2) };</p>
647 <p class="p4"><span class="Apple-tab-span"> </span>z</p>
648 <p class="p4">}.scope(1);</p>
649 <p class="p4">)</p>
650 <p class="p2"><span class="Apple-tab-span"> </span></p>
651 <p class="p5"><a href="Playback and Recording/PlayBuf.html"><b>PlayBuf</b></a></p>
652 <p class="p3">buffer playback</p>
653 <p class="p3">arguments: numChannels, buffer number, rate, trigger, start pos, loop</p>
654 <p class="p2"><br></p>
655 <p class="p6">// read sound</p>
656 <p class="p13"><span class="s5">b = </span><span class="s3">Buffer</span><span class="s5">.read(s, </span>"sounds/a11wlk01.wav"<span class="s5">);</span></p>
657 <p class="p2"><br></p>
658 <p class="p4">{ SinOsc.ar(800 + (700 * <span class="s3">PlayBuf</span>.ar(1,b, <span class="s3">BufRateScale</span>.kr(b),<span class="Apple-converted-space">  </span>loop:1)),0,0.3) }.scope(1);</p>
659 <p class="p2"><br></p>
660 <p class="p6">// loop is true</p>
661 <p class="p4">{ <span class="s3">PlayBuf</span>.ar(1,b, <span class="s3">BufRateScale</span>.kr(b), loop:1) }.scope(1);</p>
662 <p class="p14"><br></p>
663 <p class="p7"><br></p>
664 <p class="p6">// trigger one shot on each pulse</p>
665 <p class="p4">(</p>
666 <p class="p4">{</p>
667 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trig;</p>
668 <p class="p4"><span class="Apple-tab-span"> </span>trig = <span class="s3">Impulse</span>.kr(2.0);</p>
669 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">PlayBuf</span>.ar(1,b,<span class="s3">BufRateScale</span>.kr(b),trig,0,0);</p>
670 <p class="p4">}.scope(1);</p>
671 <p class="p4">)</p>
672 <p class="p7"><br></p>
673 <p class="p6">// trigger one shot on each pulse</p>
674 <p class="p4">(</p>
675 <p class="p4">{</p>
676 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trig;</p>
677 <p class="p4"><span class="Apple-tab-span"> </span>trig = <span class="s3">Impulse</span>.kr(<span class="s3">XLine</span>.kr(0.1,100,30));</p>
678 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">PlayBuf</span>.ar(1,b,<span class="s3">BufRateScale</span>.kr(b),trig,5000,0);</p>
679 <p class="p4">}.scope(1);</p>
680 <p class="p4">)</p>
681 <p class="p7"><br></p>
682 <p class="p6">// mouse control of trigger rate and startpos</p>
683 <p class="p4">(</p>
684 <p class="p4">{</p>
685 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trig;</p>
686 <p class="p4"><span class="Apple-tab-span"> </span>trig = <span class="s3">Impulse</span>.kr(<span class="s3">MouseY</span>.kr(0.5,200,1));</p>
687 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">PlayBuf</span>.ar(1,b,<span class="s3">BufRateScale</span>.kr(b),trig,<span class="s3">MouseX</span>.kr(0,<span class="s3">BufFrames</span>.kr(b)),1)</p>
688 <p class="p4">}.scope(1);</p>
689 <p class="p4">)</p>
690 <p class="p7"><br></p>
691 <p class="p6">// accelerating pitch</p>
692 <p class="p4">(</p>
693 <p class="p4">{</p>
694 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> rate;</p>
695 <p class="p4"><span class="Apple-tab-span"> </span>rate = <span class="s3">XLine</span>.kr(0.1,100,60);</p>
696 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">PlayBuf</span>.ar(1, b, rate, 1.0,0.0, 1.0)</p>
697 <p class="p4">}.scope(1);</p>
698 <p class="p4">)</p>
699 <p class="p7"><br></p>
700 <p class="p6">// sine wave control of playback rate. negative rate plays backwards</p>
701 <p class="p4">(</p>
702 <p class="p4">{</p>
703 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> rate;</p>
704 <p class="p4"><span class="Apple-tab-span"> </span>rate = <span class="s3">FSinOsc</span>.kr(<span class="s3">XLine</span>.kr(0.2,8,30), 0, 3, 0.6);</p>
705 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">PlayBuf</span>.ar(1,b,<span class="s3">BufRateScale</span>.kr(b)*rate,1,0,1)</p>
706 <p class="p4">}.scope(1);</p>
707 <p class="p4">)</p>
708 <p class="p7"><br></p>
709 <p class="p6">// zig zag around sound<span class="Apple-converted-space"> </span></p>
710 <p class="p4">(</p>
711 <p class="p4">{</p>
712 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> rate;</p>
713 <p class="p4"><span class="Apple-tab-span"> </span>rate = <span class="s3">LFNoise2</span>.kr(<span class="s3">XLine</span>.kr(1,20,60), 2);</p>
714 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">PlayBuf</span>.ar(1,b,<span class="s3">BufRateScale</span>.kr(b) * rate,1,0,1)</p>
715 <p class="p4">}.scope(1);</p>
716 <p class="p4">)</p>
717 <p class="p12"><br></p>
718 <p class="p2"><br></p>
719 <p class="p6">// free sound</p>
720 <p class="p4">b.free;</p>
721 <p class="p7"><br></p>
722 <p class="p3"><b>Granular Synthesis.</b></p>
723 <p class="p7"><br></p>
724 <p class="p5"><a href="Playback and Recording/TGrains.html"><b>TGrains</b></a></p>
725 <p class="p3">granulation of a buffer</p>
726 <p class="p3">arguments: numChannels, trigger, buffer number, rate, center pos, dur, pan, amp, interpolation</p>
727 <p class="p2"><br></p>
728 <p class="p6">// read sound</p>
729 <p class="p13"><span class="s5">b = </span><span class="s3">Buffer</span><span class="s5">.read(s, </span>"sounds/a11wlk01.wav"<span class="s5">);</span></p>
730 <p class="p2"><br></p>
731 <p class="p4">(</p>
732 <p class="p4">{</p>
733 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur;</p>
734 <p class="p4"><span class="Apple-tab-span"> </span>trate = <span class="s3">MouseY</span>.kr(2,200,1);</p>
735 <p class="p4"><span class="Apple-tab-span"> </span>dur = 4 / trate;</p>
736 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, <span class="s3">Impulse</span>.ar(trate), b, 1, <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b)), dur, 0, 0.1, 2);</p>
737 <p class="p4">}.scope(2, zoom: 4);</p>
738 <p class="p4">)</p>
739 <p class="p7"><br></p>
740 <p class="p4">(</p>
741 <p class="p4">{</p>
742 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur, clk, pos, pan;</p>
743 <p class="p4"><span class="Apple-tab-span"> </span>trate = <span class="s3">MouseY</span>.kr(8,120,1);</p>
744 <p class="p4"><span class="Apple-tab-span"> </span>dur = 12 / trate;</p>
745 <p class="p4"><span class="Apple-tab-span"> </span>clk = <span class="s3">Impulse</span>.kr(trate);</p>
746 <p class="p4"><span class="Apple-tab-span"> </span>pos = <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b)) + <span class="s3">TRand</span>.kr(0, 0.01, clk);</p>
747 <p class="p4"><span class="Apple-tab-span"> </span>pan = <span class="s3">WhiteNoise</span>.kr(0.6);</p>
748 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, clk, b, 1, pos, dur, pan, 0.1);</p>
749 <p class="p4">}.scope(2, zoom: 4);</p>
750 <p class="p4">)</p>
751 <p class="p7"><br></p>
752 <p class="p6">// 4 channels</p>
753 <p class="p4">(</p>
754 <p class="p4">{</p>
755 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur, clk, pos, pan;</p>
756 <p class="p4"><span class="Apple-tab-span"> </span>trate = <span class="s3">MouseY</span>.kr(8,120,1);</p>
757 <p class="p4"><span class="Apple-tab-span"> </span>dur = 12 / trate;</p>
758 <p class="p4"><span class="Apple-tab-span"> </span>clk = <span class="s3">Impulse</span>.kr(trate);</p>
759 <p class="p4"><span class="Apple-tab-span"> </span>pos = <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b)) + <span class="s3">TRand</span>.kr(0, 0.01, clk);</p>
760 <p class="p4"><span class="Apple-tab-span"> </span>pan = <span class="s3">WhiteNoise</span>.kr(0.6);</p>
761 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(4, clk, b, 1, pos, dur, pan, 0.1);</p>
762 <p class="p4">}.scope(4, zoom: 4);</p>
763 <p class="p4">)</p>
764 <p class="p7"><br></p>
765 <p class="p4">(</p>
766 <p class="p4">{</p>
767 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur, clk, pos, pan;</p>
768 <p class="p4"><span class="Apple-tab-span"> </span>trate = <span class="s3">MouseY</span>.kr(8,120,1);</p>
769 <p class="p4"><span class="Apple-tab-span"> </span>dur = 4 / trate;</p>
770 <p class="p4"><span class="Apple-tab-span"> </span>clk = <span class="s3">Dust</span>.kr(trate);</p>
771 <p class="p4"><span class="Apple-tab-span"> </span>pos = <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b)) + <span class="s3">TRand</span>.kr(0, 0.01, clk);</p>
772 <p class="p4"><span class="Apple-tab-span"> </span>pan = <span class="s3">WhiteNoise</span>.kr(0.6);</p>
773 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, clk, b, 1, pos, dur, pan, 0.1);</p>
774 <p class="p4">}.scope(2, zoom: 4);</p>
775 <p class="p4">)</p>
776 <p class="p7"><br></p>
777 <p class="p7"><br></p>
778 <p class="p7"><br></p>
779 <p class="p4">(</p>
780 <p class="p4">{</p>
781 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur, clk, pos, pan;</p>
782 <p class="p4"><span class="Apple-tab-span"> </span>trate = <span class="s3">LinExp</span>.kr(<span class="s3">LFTri</span>.kr(<span class="s3">MouseY</span>.kr(0.1,2,1)),-1,1,8,120);</p>
783 <p class="p4"><span class="Apple-tab-span"> </span>dur = 12 / trate;</p>
784 <p class="p4"><span class="Apple-tab-span"> </span>clk = <span class="s3">Impulse</span>.ar(trate);</p>
785 <p class="p4"><span class="Apple-tab-span"> </span>pos = <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b));</p>
786 <p class="p4"><span class="Apple-tab-span"> </span>pan = <span class="s3">WhiteNoise</span>.kr(0.6);</p>
787 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, clk, b, 1, pos, dur, pan, 0.1);</p>
788 <p class="p4">}.scope(2, zoom: 4);</p>
789 <p class="p4">)</p>
790 <p class="p7"><br></p>
791 <p class="p7"><br></p>
792 <p class="p4">(</p>
793 <p class="p4">{</p>
794 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur, clk, pos, pan;</p>
795 <p class="p4"><span class="Apple-tab-span"> </span>trate = 12;</p>
796 <p class="p4"><span class="Apple-tab-span"> </span>dur = <span class="s3">MouseY</span>.kr(0.2,24,1) / trate;</p>
797 <p class="p4"><span class="Apple-tab-span"> </span>clk = <span class="s3">Impulse</span>.kr(trate);</p>
798 <p class="p4"><span class="Apple-tab-span"> </span>pos = <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b)) + <span class="s3">TRand</span>.kr(0, 0.01, clk);</p>
799 <p class="p4"><span class="Apple-tab-span"> </span>pan = <span class="s3">WhiteNoise</span>.kr(0.6);</p>
800 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, clk, b, 1, pos, dur, pan, 0.1);</p>
801 <p class="p4">}.scope(2, zoom: 4);</p>
802 <p class="p4">)</p>
803 <p class="p7"><br></p>
804 <p class="p4">(</p>
805 <p class="p4">{</p>
806 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur, clk, pos, pan;</p>
807 <p class="p4"><span class="Apple-tab-span"> </span>trate = 100;</p>
808 <p class="p4"><span class="Apple-tab-span"> </span>dur = 8 / trate;</p>
809 <p class="p4"><span class="Apple-tab-span"> </span>clk = <span class="s3">Impulse</span>.kr(trate);</p>
810 <p class="p4"><span class="Apple-tab-span"> </span>pos = <span class="s3">Integrator</span>.kr(<span class="s3">BrownNoise</span>.kr(0.001));</p>
811 <p class="p4"><span class="Apple-tab-span"> </span>pan = <span class="s3">WhiteNoise</span>.kr(0.6);</p>
812 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, clk, b, 1, pos, dur, pan, 0.1);</p>
813 <p class="p4">}.scope(2, zoom: 4);</p>
814 <p class="p4">)</p>
815 <p class="p7"><br></p>
816 <p class="p4">(</p>
817 <p class="p4">{</p>
818 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur, clk, pos, pan;</p>
819 <p class="p4"><span class="Apple-tab-span"> </span>trate = <span class="s3">MouseY</span>.kr(1,400,1);</p>
820 <p class="p4"><span class="Apple-tab-span"> </span>dur = 8 / trate;</p>
821 <p class="p4"><span class="Apple-tab-span"> </span>clk = <span class="s3">Impulse</span>.kr(trate);</p>
822 <p class="p4"><span class="Apple-tab-span"> </span>pos = <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b));</p>
823 <p class="p4"><span class="Apple-tab-span"> </span>pan = <span class="s3">WhiteNoise</span>.kr(0.8);</p>
824 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, clk, b, 2 ** <span class="s3">WhiteNoise</span>.kr(2), pos, dur, pan, 0.1);</p>
825 <p class="p4">}.scope(2, zoom: 4);</p>
826 <p class="p4">)</p>
827 <p class="p7"><br></p>
828 <p class="p7"><br></p>
829 <p class="p7"><br></p>
830 <p class="p7"><br></p>
831 <p class="p4">(</p>
832 <p class="p4">{</p>
833 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trate, dur;</p>
834 <p class="p4"><span class="Apple-tab-span"> </span>trate = <span class="s3">MouseY</span>.kr(2,120,1);</p>
835 <p class="p4"><span class="Apple-tab-span"> </span>dur = 1.2 / trate;</p>
836 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">TGrains</span>.ar(2, <span class="s3">Impulse</span>.ar(trate), b, (1.2 ** <span class="s3">WhiteNoise</span>.kr(3).round(1)), <span class="s3">MouseX</span>.kr(0,<span class="s3">BufDur</span>.kr(b)), dur, <span class="s3">WhiteNoise</span>.kr(0.6), 0.1);</p>
837 <p class="p4">}.scope(2, zoom: 4);</p>
838 <p class="p4">)</p>
839 <p class="p7"><br></p>
840 <p class="p6">// free sound</p>
841 <p class="p4">b.free;</p>
842 <p class="p2"><br></p>
843 <p class="p5"><span class="s4"><a href="Generators/Granular/GrainSin.html">GrainSin</a></span></p>
844 <p class="p3">arguments: numChannels, trigger, dur, freq, pan, envbufnum</p>
845 <p class="p7"><br></p>
846 <p class="p15"><span class="s5">( </span>// using default window</p>
847 <p class="p4">{</p>
848 <p class="p4"><span class="Apple-tab-span"> </span><span class="s12">var</span> trigrate, winsize, trig;</p>
849 <p class="p4"><span class="Apple-tab-span"> </span>trigrate = <span class="s12">MouseX</span>.kr(2, 120);</p>
850 <p class="p4"><span class="Apple-tab-span"> </span>winsize = trigrate.reciprocal;</p>
851 <p class="p4"><span class="Apple-tab-span"> </span>trig = <span class="s12">Impulse</span>.ar(trigrate);</p>
852 <p class="p4"><span class="Apple-tab-span"> </span><span class="s12">GrainSin</span>.ar(2, trig, winsize, <span class="s12">TRand</span>.ar(440.0, 880.0, trig), <span class="s12">LFNoise1</span>.kr(0.2),</p>
853 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>-1, 0.2)</p>
854 <p class="p4">}.scope(2, zoom: 4);</p>
855 <p class="p4">)</p>
856 <p class="p2"><br></p>
857 <p class="p16"><span class="s13">b =</span> <span class="s12">Buffer</span>.sendCollection(s, <span class="s12">Env</span>([0, 1, 0], [0.5, 0.5], [8, -8]).discretize, 1);</p>
858 <p class="p2"><br></p>
859 <p class="p15"><span class="s5">( </span>// using user supplied window</p>
860 <p class="p4">{</p>
861 <p class="p4"><span class="Apple-tab-span"> </span><span class="s12">var</span> trigrate, winsize, trig;</p>
862 <p class="p4"><span class="Apple-tab-span"> </span>trigrate = <span class="s12">MouseX</span>.kr(2, 120);</p>
863 <p class="p4"><span class="Apple-tab-span"> </span>winsize = trigrate.reciprocal;</p>
864 <p class="p4"><span class="Apple-tab-span"> </span>trig = <span class="s12">Impulse</span>.ar(trigrate);</p>
865 <p class="p4"><span class="Apple-tab-span"> </span><span class="s12">GrainSin</span>.ar(2, trig, winsize, <span class="s12">TRand</span>.ar(440.0, 880.0, trig), <span class="s12">LFNoise1</span>.kr(0.2),</p>
866 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b, 0.2)</p>
867 <p class="p4">}.scope(2, zoom: 4);</p>
868 <p class="p4">)</p>
869 <p class="p2"><br></p>
870 <p class="p5"><span class="s5">see also <a href="Generators/Granular/GrainFM.html"><span class="s4">GrainFM</span></a>, <a href="Generators/Granular/GrainBuf.html"><span class="s4">GrainBuf</span></a> and <a href="Generators/Granular/GrainIn.html"><span class="s4">GrainIn</span></a></span></p>
871 <p class="p2"><br></p>
872 <p class="p3"><b>Control</b></p>
873 <p class="p2"><br></p>
874 <p class="p3">Filters for Controls</p>
875 <p class="p2"><br></p>
876 <p class="p5"><span class="s4"><a href="Synth control/Envelopes/Decay.html">Decay</a></span></p>
877 <p class="p3">triggered exponential decay</p>
878 <p class="p3">arguments: in, decay time, mul, add</p>
879 <p class="p2"><br></p>
880 <p class="p4">{ <span class="s3">WhiteNoise</span>.ar * <span class="s3">Decay</span>.ar(<span class="s3">Impulse</span>.ar(1), 0.9, 0.2) }.scope(1, zoom:4);</p>
881 <p class="p4">{ <span class="s3">WhiteNoise</span>.ar * <span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(3), 0.9, 0.2) }.scope(1, zoom:4);</p>
882 <p class="p4">{ <span class="s3">SinOsc</span>.ar(<span class="s3">Decay</span>.ar(<span class="s3">Dust</span>.ar(4), 0.5, 1000, 400), 0, 0.2) }.scope(1, zoom:4);</p>
883 <p class="p2"><br></p>
884 <p class="p5"><span class="s4"><a href="Synth control/Envelopes/Decay2.html">Decay2</a></span></p>
885 <p class="p3">triggered exponential attack and exponential decay<span class="Apple-converted-space"> </span></p>
886 <p class="p3">arguments: trigger, attack time, decay time, mul, add</p>
887 <p class="p2"><br></p>
888 <p class="p4">{ <span class="s3">WhiteNoise</span>.ar * <span class="s3">Decay2</span>.ar(<span class="s3">Impulse</span>.ar(1), 0.2, 0.9, 0.2) }.scope(1, zoom:4);</p>
889 <p class="p4">{ <span class="s3">WhiteNoise</span>.ar * <span class="s3">Decay2</span>.ar(<span class="s3">Dust</span>.ar(3), 0.2, 0.9, 0.2) }.scope(1, zoom:4);</p>
890 <p class="p2"><br></p>
891 <p class="p5"><span class="s4"><a href="Filters/Lag.html">Lag</a></span></p>
892 <p class="p3">arguments: trigger, duration</p>
893 <p class="p2"><br></p>
894 <p class="p4">{ <span class="s3">SinOsc</span>.ar(<span class="s3">Lag</span>.ar(<span class="s3">LFPulse</span>.ar(2,0,0.5,800,400), <span class="s3">MouseX</span>.kr(0,0.5)), 0, 0.2) }.scope(1, zoom:4);</p>
895 <p class="p2"><br></p>
896 <p class="p5"><span class="s4"><a href="Synth control/Integrator.html">Integrator</a></span></p>
897 <p class="p3">leaky integrator</p>
898 <p class="p2"><br></p>
899 <p class="p4">{ <span class="s3">SinOsc</span>.ar(<span class="s3">Integrator</span>.ar(<span class="s3">Dust2</span>.ar(8), 0.99999, 200, 800), 0, 0.2) }.scope(1)</p>
900 <p class="p2"><br></p>
901 <p class="p2"><br></p>
902 <p class="p3">Triggers</p>
903 <p class="p2"><br></p>
904 <p class="p5"><span class="s4"><a href="Triggers/Trig.html">Trig</a></span><span class="s5">, <a href="Triggers/Trig1.html"><span class="s4">Trig1</span></a></span></p>
905 <p class="p3">timed duration gate</p>
906 <p class="p3">arguments: trigger, duration</p>
907 <p class="p2"><br></p>
908 <p class="p6">// amplitude determined by amplitude of trigger</p>
909 <p class="p4">{ <span class="s3">Trig</span>.ar(<span class="s3">Dust</span>.ar(2), 0.2) * <span class="s3">FSinOsc</span>.ar(800, 0, 0.4) }.scope(1, zoom:4);</p>
910 <p class="p6">// amplitude always the same.</p>
911 <p class="p4">{ <span class="s3">Trig1</span>.ar(<span class="s3">Dust</span>.ar(2), 0.2) * <span class="s3">FSinOsc</span>.ar(800, 0, 0.4) }.scope(1, zoom:4)</p>
912 <p class="p2"><br></p>
913 <p class="p5"><span class="s4"><a href="Triggers/TDelay.html">TDelay</a></span></p>
914 <p class="p3">delays a trigger. only delays one pending trigger at a time.</p>
915 <p class="p3">arguments: trigger, delay time</p>
916 <p class="p2"><br></p>
917 <p class="p4">(</p>
918 <p class="p4">{<span class="Apple-converted-space"> </span></p>
919 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> trig;</p>
920 <p class="p4"><span class="Apple-tab-span"> </span>trig = <span class="s3">Dust</span>.ar(2);</p>
921 <p class="p4"><span class="Apple-tab-span"> </span>[(<span class="s3">Trig1</span>.ar(trig, 0.05) * <span class="s3">FSinOsc</span>.ar(600, 0, 0.2)),</p>
922 <p class="p4"><span class="Apple-tab-span"> </span>(<span class="s3">Trig1</span>.ar(<span class="s3">TDelay</span>.ar(trig, 0.1), 0.05) * <span class="s3">FSinOsc</span>.ar(800, 0, 0.2))]</p>
923 <p class="p4">}.scope(2, zoom:4);</p>
924 <p class="p4">)</p>
925 <p class="p7"><br></p>
926 <p class="p5"><span class="s4"><a href="Synth control/Latch.html">Latch</a></span></p>
927 <p class="p3">sample and hold</p>
928 <p class="p3">arguments: in, trigger</p>
929 <p class="p7"><br></p>
930 <p class="p4">{ <span class="s3">Blip</span>.ar(<span class="s3">Latch</span>.ar(<span class="s3">WhiteNoise</span>.ar, <span class="s3">Impulse</span>.ar(9)) * 400 + 500, 4, 0.2) }.play;</p>
931 <p class="p4">{ <span class="s3">Blip</span>.ar(<span class="s3">Latch</span>.ar(<span class="s3">SinOsc</span>.ar(0.3), <span class="s3">Impulse</span>.ar(9)) * 400 + 500, 4, 0.2) }.play;</p>
932 <p class="p7"><br></p>
933 <p class="p5"><span class="s4"><a href="Triggers/Gate.html">Gate</a></span></p>
934 <p class="p3">pass or hold</p>
935 <p class="p3">arguments: in, trigger</p>
936 <p class="p7"><br></p>
937 <p class="p4">{ <span class="s3">Blip</span>.ar(<span class="s3">Gate</span>.ar(<span class="s3">LFNoise2</span>.ar(40), <span class="s3">LFPulse</span>.ar(1)) * 400 + 500, 4, 0.2) }.scope(1, zoom:4);</p>
938 <p class="p7"><br></p>
939 <p class="p7"><br></p>
940 <p class="p5"><span class="s4"><a href="Triggers/PulseCount.html">PulseCount</a></span></p>
941 <p class="p3">count triggers</p>
942 <p class="p3">arguments: trigger, reset</p>
943 <p class="p7"><br></p>
944 <p class="p4">(</p>
945 <p class="p4">{</p>
946 <p class="p17">SinOsc<span class="s5">.ar(</span></p>
947 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">PulseCount</span>.ar(<span class="s3">Impulse</span>.ar(10), <span class="s3">Impulse</span>.ar(0.4)) * 200,<span class="Apple-converted-space"> </span></p>
948 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0, 0.05</p>
949 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
950 <p class="p4">}.scope(2, zoom:4);</p>
951 <p class="p4">)</p>
952 <p class="p7"><br></p>
953 <p class="p5"><span class="s4"><a href="Triggers/PulseDivider.html">PulseDivider</a></span></p>
954 <p class="p3">arguments: trigger, div, start</p>
955 <p class="p7"><br></p>
956 <p class="p17">(</p>
957 <p class="p4">{<span class="Apple-tab-span"> </span></p>
958 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> p, a, b;</p>
959 <p class="p4"><span class="Apple-tab-span"> </span>p = <span class="s3">Impulse</span>.ar(8);</p>
960 <p class="p4"><span class="Apple-tab-span"> </span>a = <span class="s3">SinOsc</span>.ar(1200, 0, <span class="s3">Decay2</span>.ar(p, 0.005, 0.1));</p>
961 <p class="p4"><span class="Apple-tab-span"> </span>b = <span class="s3">SinOsc</span>.ar(600,<span class="Apple-converted-space">  </span>0, <span class="s3">Decay2</span>.ar(<span class="s3">PulseDivider</span>.ar(p, <span class="s3">MouseX</span>.kr(1,8).round(1)), 0.005, 0.5));</p>
962 <p class="p7"><span class="Apple-tab-span"> </span></p>
963 <p class="p4"><span class="Apple-tab-span"> </span>[a, b] * 0.4</p>
964 <p class="p4">}.scope(2, zoom:4);</p>
965 <p class="p4">)</p>
966 <p class="p7"><br></p>
967 <p class="p7"><br></p>
968 <p class="p5"><span class="s4"><a href="Synth control/Envelopes/EnvGen.html">EnvGen</a></span></p>
969 <p class="p3">envelope generator</p>
970 <p class="p3">envelope is specified using an instance of the Env class.</p>
971 <p class="p7"><br></p>
972 <p class="p4">{ <span class="s3">EnvGen</span>.kr(<span class="s3">Env</span>.perc, doneAction:2) * <span class="s3">SinOsc</span>.ar(880,0,0.2) }.play;</p>
973 <p class="p4">{ <span class="s3">EnvGen</span>.kr(<span class="s3">Env</span>.perc(1,0.005,1,4), doneAction:2) * <span class="s3">SinOsc</span>.ar(880,0,0.2) }.play;</p>
974 <p class="p7"><br></p>
975 <p class="p4">{ <span class="s3">EnvGen</span>.kr(<span class="s3">Env</span>.perc, Impulse.kr(2)) * <span class="s3">SinOsc</span>.ar(880,0,0.2) }.play;</p>
976 <p class="p4">{ <span class="s3">EnvGen</span>.kr(<span class="s3">Env</span>.perc, Dust.kr(3)) * <span class="s3">SinOsc</span>.ar(880,0,0.2) }.play;</p>
977 <p class="p7"><br></p>
978 <p class="p6">// for sustain envelopes a gate is required</p>
979 <p class="p4">z = { <span class="s3">arg</span> gate=1; <span class="s3">EnvGen</span>.kr(<span class="s3">Env</span>.adsr, gate, doneAction:2) * <span class="s3">SinOsc</span>.ar(880,0,0.2) }.play;</p>
980 <p class="p4">z.release;</p>
981 <p class="p2"><br></p>
982 <p class="p4">(</p>
983 <p class="p6">// randomly generated envelope</p>
984 <p class="p4">z = { <span class="s3">arg</span> gate=1;<span class="Apple-converted-space"> </span></p>
985 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> env, n=32;</p>
986 <p class="p4"><span class="Apple-tab-span"> </span>env = <span class="s3">Env</span>(</p>
987 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[0]++{1.0.rand.squared}.dup(n-1) ++ [0],<span class="Apple-converted-space"> </span></p>
988 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{rrand(0.005,0.2)}.dup(n),</p>
989 <p class="p4"><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="s8">\lin</span>, n-8, 8 );</p>
990 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">EnvGen</span>.kr(env, gate, doneAction: 2) * <span class="s3">LFTri</span>.ar(220,0,0.4)<span class="Apple-converted-space"> </span></p>
991 <p class="p4">}.scope(1, zoom:4);</p>
992 <p class="p4">)</p>
993 <p class="p4">z.release;</p>
994 <p class="p2"><br></p>
995 <p class="p3"><b>Spectral</b></p>
996 <p class="p2"><br></p>
997 <p class="p3"><span class="s7"><a href="FFT/FFT.html">FFT</a></span>, <a href="FFT/IFFT.html"><span class="s9">IFFT</span></a> and the phase vocoder ugens.</p>
998 <p class="p2"><br></p>
999 <p class="p3">FFT calculates the spectrum of a sound, puts it into a buffer, and outputs a trigger each time the</p>
1000 <p class="p3">buffer is ready to process. The PV UGens process the spectrum when they receive the trigger.</p>
1001 <p class="p3">IFFT converts the spectrum back into sound.</p>
1002 <p class="p2"><br></p>
1003 <p class="p7"><br></p>
1004 <p class="p6">// alloc a buffer for the FFT</p>
1005 <p class="p4">b = <span class="s3">Buffer</span>.alloc(s,2048,1);</p>
1006 <p class="p6">// read a sound</p>
1007 <p class="p13"><span class="s5">c = </span><span class="s3">Buffer</span><span class="s5">.read(s, </span>"sounds/a11wlk01.wav"<span class="s5">);</span></p>
1008 <p class="p7"><br></p>
1009 <p class="p7"><br></p>
1010 <p class="p4">(</p>
1011 <p class="p6">// do nothing</p>
1012 <p class="p4">{</p>
1013 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in, chain;</p>
1014 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">PlayBuf</span>.ar(1,c, <span class="s3">BufRateScale</span>.kr(c), loop:1);</p>
1015 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">FFT</span>(b, in);</p>
1016 <p class="p4"><span class="Apple-tab-span"> </span>0.5 * <span class="s3">IFFT</span>(chain);</p>
1017 <p class="p4">}.scope(1);</p>
1018 <p class="p4">)</p>
1019 <p class="p7"><br></p>
1020 <p class="p4">(</p>
1021 <p class="p6">// pass only magnitudes above a threshold</p>
1022 <p class="p4">{</p>
1023 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in, chain;</p>
1024 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">PlayBuf</span>.ar(1,c, <span class="s3">BufRateScale</span>.kr(c), loop:1);</p>
1025 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">FFT</span>(b, in);</p>
1026 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">PV_MagAbove</span>(chain, <span class="s3">MouseX</span>.kr(0.1,512,1));<span class="Apple-converted-space"> </span></p>
1027 <p class="p4"><span class="Apple-tab-span"> </span>0.5 * <span class="s3">IFFT</span>(chain);</p>
1028 <p class="p4">}.scope(1);</p>
1029 <p class="p4">)</p>
1030 <p class="p7"><br></p>
1031 <p class="p4">(</p>
1032 <p class="p6">// pass only magnitudes below a threshold</p>
1033 <p class="p4">{</p>
1034 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in, chain;</p>
1035 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">PlayBuf</span>.ar(1,c, <span class="s3">BufRateScale</span>.kr(c), loop:1);</p>
1036 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">FFT</span>(b, in);</p>
1037 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">PV_MagBelow</span>(chain, <span class="s3">MouseX</span>.kr(0.1,512,1));<span class="Apple-converted-space"> </span></p>
1038 <p class="p4"><span class="Apple-tab-span"> </span>0.5 * <span class="s3">IFFT</span>(chain);</p>
1039 <p class="p4">}.scope(1);</p>
1040 <p class="p4">)</p>
1041 <p class="p7"><br></p>
1042 <p class="p4">(</p>
1043 <p class="p6">// brick wall filter.</p>
1044 <p class="p4">{</p>
1045 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in, chain;</p>
1046 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">PlayBuf</span>.ar(1,c, <span class="s3">BufRateScale</span>.kr(c), loop:1);</p>
1047 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">FFT</span>(b, in);</p>
1048 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">PV_BrickWall</span>(chain, <span class="s3">MouseX</span>.kr(-1,1));<span class="Apple-converted-space"> </span></p>
1049 <p class="p4"><span class="Apple-tab-span"> </span>0.5 * <span class="s3">IFFT</span>(chain);</p>
1050 <p class="p4">}.scope(1);</p>
1051 <p class="p4">)</p>
1052 <p class="p7"><br></p>
1053 <p class="p4">(</p>
1054 <p class="p6">// pass random frequencies. Mouse controls how many to pass.</p>
1055 <p class="p6">// trigger changes the frequencies periodically</p>
1056 <p class="p4">{</p>
1057 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in, chain;</p>
1058 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">PlayBuf</span>.ar(1,c, <span class="s3">BufRateScale</span>.kr(c), loop:1);</p>
1059 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">FFT</span>(b, in);</p>
1060 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">PV_RandComb</span>(chain, <span class="s3">MouseX</span>.kr(0,1), <span class="s3">Impulse</span>.kr(0.4));</p>
1061 <p class="p4"><span class="Apple-tab-span"> </span>0.5 * <span class="s3">IFFT</span>(chain);</p>
1062 <p class="p4">}.scope(1);</p>
1063 <p class="p4">)</p>
1064 <p class="p7"><br></p>
1065 <p class="p4">(</p>
1066 <p class="p6">// rectangular comb filter</p>
1067 <p class="p4">{</p>
1068 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in, chain;</p>
1069 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">PlayBuf</span>.ar(1,c, <span class="s3">BufRateScale</span>.kr(c), loop:1);</p>
1070 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">FFT</span>(b, in);</p>
1071 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">PV_RectComb</span>(chain, 8, <span class="s3">MouseY</span>.kr(0,1), <span class="s3">MouseX</span>.kr(0,1));</p>
1072 <p class="p4"><span class="Apple-tab-span"> </span>0.5 * <span class="s3">IFFT</span>(chain);</p>
1073 <p class="p4">}.scope(1);</p>
1074 <p class="p4">)</p>
1075 <p class="p7"><br></p>
1076 <p class="p4">(</p>
1077 <p class="p6">// freeze magnitudes</p>
1078 <p class="p4">{</p>
1079 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> in, chain;</p>
1080 <p class="p4"><span class="Apple-tab-span"> </span>in = <span class="s3">PlayBuf</span>.ar(1,c, <span class="s3">BufRateScale</span>.kr(c), loop:1);</p>
1081 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">FFT</span>(b, in);</p>
1082 <p class="p4"><span class="Apple-tab-span"> </span>chain = <span class="s3">PV_MagFreeze</span>(chain, <span class="s3">LFPulse</span>.kr(1, 0.75));</p>
1083 <p class="p4"><span class="Apple-tab-span"> </span>0.5 * <span class="s3">IFFT</span>(chain);</p>
1084 <p class="p4">}.scope(1);</p>
1085 <p class="p4">)</p>
1086 <p class="p7"><br></p>
1087 <p class="p8"><br></p>
1088 <p class="p3"><b>2. Techniques</b></p>
1089 <p class="p2"><br></p>
1090 <p class="p3"><b>Artificial Space</b></p>
1091 <p class="p3">Building a sense of space into a sound by setting up phase differences between the speakers.</p>
1092 <p class="p8"><br></p>
1093 <p class="p7"><br></p>
1094 <p class="p4">{ <span class="s3">var</span> x; x = <span class="s3">BrownNoise</span>.ar(0.2); [x,x] }.scope(2); <span class="s6">// correlated</span></p>
1095 <p class="p4">{ {<span class="s3">BrownNoise</span>.ar(0.2)}.dup }.scope(2); <span class="s6">// not correlated</span></p>
1096 <p class="p7"><br></p>
1097 <p class="p6">// correlated</p>
1098 <p class="p4">{ <span class="s3">var</span> x; x = <span class="s3">LPF</span>.ar(<span class="s3">BrownNoise</span>.ar(0.2), <span class="s3">MouseX</span>.kr(100,10000)); [x,x] }.scope(2);</p>
1099 <p class="p6">// not correlated</p>
1100 <p class="p4">{ <span class="s3">LPF</span>.ar({<span class="s3">BrownNoise</span>.ar(0.2)}.dup, <span class="s3">MouseX</span>.kr(100,10000)) }.scope(2);</p>
1101 <p class="p7"><br></p>
1102 <p class="p7"><br></p>
1103 <p class="p6">// correlated</p>
1104 <p class="p4">(</p>
1105 <p class="p4">{ <span class="s3">var</span> x;<span class="Apple-converted-space"> </span></p>
1106 <p class="p4"><span class="Apple-tab-span"> </span>x = <span class="s3">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s3">nil</span>, [1, 1, 1, 1]], <span class="s3">PinkNoise</span>.ar(7e-3));<span class="Apple-converted-space"> </span></p>
1107 <p class="p4"><span class="Apple-tab-span"> </span>[x,x]<span class="Apple-converted-space"> </span></p>
1108 <p class="p4">}.scope(2))</p>
1109 <p class="p6">// not correlated</p>
1110 <p class="p4">{ <span class="s3">Klank</span>.ar(`[[200, 671, 1153, 1723], <span class="s3">nil</span>, [1, 1, 1, 1]], <span class="s3">PinkNoise</span>.ar([7e-3,7e-3])) }.scope(2);</p>
1111 <p class="p7"><br></p>
1112 <p class="p6">// two waves mixed together coming out both speakers</p>
1113 <p class="p4">{ <span class="s3">var</span> x; x = <span class="s3">Mix</span>.ar(<span class="s3">VarSaw</span>.ar([100,101], 0, 0.1, 0.2)); [x,x] }.scope(2);</p>
1114 <p class="p6">// two waves coming out each speaker independantly</p>
1115 <p class="p4">{ <span class="s3">VarSaw</span>.ar([100,101], 0, 0.1, 0.2 * 1.414) }.scope(2); <span class="s6">// * 1.414 to compensate for power</span></p>
1116 <p class="p7"><br></p>
1117 <p class="p6">// delays as cues to direction</p>
1118 <p class="p6">// mono</p>
1119 <p class="p4">{ <span class="s3">var</span> x; x = <span class="s3">LFTri</span>.ar(1000,0,<span class="s3">Decay2</span>.ar(<span class="s3">Impulse</span>.ar(4,0,0.2),0.004,0.2)); [x,x]}.scope(2);</p>
1120 <p class="p7"><br></p>
1121 <p class="p4">(</p>
1122 <p class="p6">// inter-speaker delays</p>
1123 <p class="p4">{ <span class="s3">var</span> x; x = <span class="s3">LFTri</span>.ar(1000,0,<span class="s3">Decay2</span>.ar(<span class="s3">Impulse</span>.ar(4,0,0.2),0.004,0.2));<span class="Apple-converted-space"> </span></p>
1124 <p class="p4"><span class="Apple-tab-span"> </span>[<span class="s3">DelayC</span>.ar(x,0.01,0.01),<span class="s3">DelayC</span>.ar(x,0.02,<span class="s3">MouseX</span>.kr(0.02, 0))]</p>
1125 <p class="p4">}.scope(2);</p>
1126 <p class="p4">)</p>
1127 <p class="p7"><br></p>
1128 <p class="p4">(</p>
1129 <p class="p6">// mixing two delays together</p>
1130 <p class="p6">// you hear a phasing sound but the sound is still flat.</p>
1131 <p class="p4">{ <span class="s3">var</span> x; x = <span class="s3">BrownNoise</span>.ar(0.2);<span class="Apple-converted-space"> </span></p>
1132 <p class="p4"><span class="Apple-tab-span"> </span>x = <span class="s3">Mix</span>.ar([<span class="s3">DelayC</span>.ar(x,0.01,0.01),<span class="s3">DelayC</span>.ar(x,0.02,<span class="s3">MouseX</span>.kr(0,0.02))]);</p>
1133 <p class="p4"><span class="Apple-tab-span"> </span>[x,x]</p>
1134 <p class="p4">}.scope(2);</p>
1135 <p class="p4">)</p>
1136 <p class="p7"><br></p>
1137 <p class="p4">(</p>
1138 <p class="p6">// more spatial sounding. phasing causes you to perceive directionality</p>
1139 <p class="p4">{ <span class="s3">var</span> x; x = <span class="s3">BrownNoise</span>.ar(0.2);<span class="Apple-converted-space"> </span></p>
1140 <p class="p4"><span class="Apple-tab-span"> </span>[<span class="s3">DelayC</span>.ar(x,0.01,0.01),<span class="s3">DelayC</span>.ar(x,0.02,<span class="s3">MouseX</span>.kr(0.02, 0))]</p>
1141 <p class="p4">}.scope(2);</p>
1142 <p class="p4">)</p>
1143 <p class="p7"><br></p>
1144 <p class="p7"><br></p>
1145 <p class="p3"><b>Parallel Structures</b></p>
1146 <p class="p7"><br></p>
1147 <p class="p4">(</p>
1148 <p class="p4">{</p>
1149 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// mixing sine oscillators in parallel</p>
1150 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span><span class="s3">var</span><span class="s5"> n = 16; </span>// number of structures to make</p>
1151 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// mix together<span class="Apple-converted-space">  </span>parallel structures</p>
1152 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">Mix</span>.fill(n,<span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span></p>
1153 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// this function creates an oscillator at a random frequency</p>
1154 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ <span class="s3">FSinOsc</span>.ar(200 + 1000.0.rand) }</p>
1155 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span>) / (2*n)<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// scale amplitude</p>
1156 <p class="p4">}.scope(1);</p>
1157 <p class="p4">)</p>
1158 <p class="p7"><br></p>
1159 <p class="p4">(</p>
1160 <p class="p4">{</p>
1161 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// mixing sine oscillators in parallel</p>
1162 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span><span class="s3">var</span><span class="s5"> n = 16; </span>// number of structures to make</p>
1163 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// mix together<span class="Apple-converted-space">  </span>parallel structures</p>
1164 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">Mix</span>.fill(n,<span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span></p>
1165 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// this function creates an oscillator at a random frequency</p>
1166 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ <span class="s3">FSinOsc</span>.ar(200 + 1000.0.rand + [0, 0.5]) }</p>
1167 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span>) / (2*n)<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// scale amplitude</p>
1168 <p class="p4">}.scope(2);</p>
1169 <p class="p4">)</p>
1170 <p class="p7"><br></p>
1171 <p class="p4">(</p>
1172 <p class="p4">{</p>
1173 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// mixing sine oscillators in parallel</p>
1174 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span><span class="s3">var</span><span class="s5"> n = 16; </span>// number of structures to make</p>
1175 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span>// mix together<span class="Apple-converted-space">  </span>parallel structures</p>
1176 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">Mix</span>.fill(n,<span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span></p>
1177 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{<span class="Apple-converted-space"> </span></p>
1178 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>var amp;</p>
1179 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>amp = <span class="s3">FSinOsc</span>.kr(exprand(0.1,1),2pi.rand).max(0);</p>
1180 <p class="p4"><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">Pan2</span>.ar(</p>
1181 <p class="p4"><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">FSinOsc</span>.ar(exprand(100,1000.0), 0, amp),</p>
1182 <p class="p4"><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>1.0.rand2)</p>
1183 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</p>
1184 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span>) / (2*n)<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// scale amplitude</p>
1185 <p class="p4">}.scope(2);</p>
1186 <p class="p4">)</p>
1187 <p class="p7"><br></p>
1188 <p class="p7"><br></p>
1189 <p class="p4">(</p>
1190 <p class="p4">{</p>
1191 <p class="p4"><span class="Apple-tab-span"> </span><span class="s3">var</span> n;</p>
1192 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span>n = 8; </span>// number of 'voices'</p>
1193 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span></span><span class="s3">Mix</span><span class="s5">.ar( </span>// mix all stereo pairs down.</p>
1194 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s3">Pan2</span><span class="s5">.ar( </span>// pan the voice to a stereo position</p>
1195 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s3">CombL</span><span class="s5">.ar( </span>// a comb filter used as a string resonator</p>
1196 <p class="p6"><span class="s5"><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 class="s3">Dust</span><span class="s5">.ar( </span>// random impulses as an excitation function</p>
1197 <p class="p6"><span class="s5"><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>// an array to cause expansion of Dust to n channels</p>
1198 <p class="p6"><span class="s5"><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>// 1 means one impulse per second on average</p>
1199 <p class="p4"><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>1.dup(n),<span class="Apple-converted-space"> </span></p>
1200 <p class="p6"><span class="s5"><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>0.3 </span>// amplitude</p>
1201 <p class="p4"><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-converted-space"> </span></p>
1202 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0.01, </span>// max delay time in seconds</p>
1203 <p class="p6"><span class="s5"><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>// array of different random lengths for each 'string'</p>
1204 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{0.004.rand+0.0003}.dup(n),<span class="Apple-converted-space"> </span></p>
1205 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>4 </span>// decay time in seconds</p>
1206 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>),</p>
1207 <p class="p6"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{1.0.rand2}.dup(n) </span>// give each voice a different pan position</p>
1208 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
1209 <p class="p4"><span class="Apple-tab-span"> </span>)</p>
1210 <p class="p4">}.scope(2, zoom:4);</p>
1211 <p class="p4">)</p>
1212 </body>
1213 </html>