polymorphism: better names for .binaryValue and .booleanValue are .asInteger and...
[supercollider.git] / Help / Collections / Harmonics.html
blob2af297648486d8a1102181700d42a1854446563c
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">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
20 span.s1 {color: #000000}
21 span.s2 {color: #0000bf}
22 span.s3 {color: #606060}
23 span.s4 {color: #007300}
24 span.Apple-tab-span {white-space:pre}
25 </style>
26 </head>
27 <body>
28 <p class="p1"><b>Harmonics</b></p>
29 <p class="p2"><br></p>
30 <p class="p3">Harmonics objects are convenient factories for creating Arrays that are used to fill buffers using the b_gen sine fill commands on the server.</p>
31 <p class="p2"><br></p>
32 <p class="p4"><b>Class Methods</b></p>
33 <p class="p2"><br></p>
34 <p class="p3"><b>*new(size)</b></p>
35 <p class="p2"><br></p>
36 <p class="p3">Create a new Harmonics array of size. Nothing is filled in for you, until instance methods are applied.</p>
37 <p class="p2"><br></p>
38 <p class="p5"><span class="s1">a = </span><span class="s2">Harmonics</span><span class="s1">.new(16); </span>// just returns an instance of Harmonics with size</p>
39 <p class="p6"><br></p>
40 <p class="p4"><b>Instance Methods</b></p>
41 <p class="p2"><br></p>
42 <p class="p3"><b>ramp(start, step)</b></p>
43 <p class="p2"><br></p>
44 <p class="p5"><span class="s1">a.ramp(1.0, 1.0); </span>// returns a harmonic series</p>
45 <p class="p7"><br></p>
46 <p class="p8">b = <span class="s2">Buffer</span>.alloc(s, 512, 1);</p>
47 <p class="p5">// harmonic series for freqs, ramp down for amps</p>
48 <p class="p8">b.sine2(a.ramp(1.0, 1.0).postln, a.ramp(0.5, -0.025).postln, <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
49 <p class="p7"><br></p>
50 <p class="p8">z = <span class="s2">SynthDef</span>(<span class="s3">"help-Osc"</span>,{ <span class="s2">arg</span> out=0,bufnum=0;</p>
51 <p class="p8"><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(out,</p>
52 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Osc</span>.ar(bufnum, 200, 0, 0.5)</p>
53 <p class="p8"><span class="Apple-tab-span"> </span>)</p>
54 <p class="p8">});</p>
55 <p class="p7"><br></p>
56 <p class="p8">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
57 <p class="p7"><br></p>
58 <p class="p8">y.free;</p>
59 <p class="p2"><br></p>
60 <p class="p3"><b>decay(k) - 1 / ((i+1 ** k)</b></p>
61 <p class="p2"><br></p>
62 <p class="p9">a.decay(1.0);<span class="Apple-converted-space"> </span></p>
63 <p class="p10"><br></p>
64 <p class="p9">b.sine2(a.ramp(1.0, 1.0).postln, a.decay(1.0).postln, <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
65 <p class="p10"><br></p>
66 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
67 <p class="p10"><br></p>
68 <p class="p9">y.free;</p>
69 <p class="p10"><br></p>
70 <p class="p3"><b>geom(k) - 1 / (i ** k)</b></p>
71 <p class="p2"><br></p>
72 <p class="p9">a.geom(1.2);<span class="Apple-converted-space"> </span></p>
73 <p class="p10"><br></p>
74 <p class="p9">b.sine2(a.ramp(1.0, 1.0).postln, a.geom(1.2).postln, <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
75 <p class="p10"><br></p>
76 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
77 <p class="p10"><br></p>
78 <p class="p9">y.free;</p>
79 <p class="p10"><br></p>
80 <p class="p3"><b>formant(center, width) - create a formant like structure</b></p>
81 <p class="p2"><br></p>
82 <p class="p9">a.formant(6, 3);<span class="Apple-converted-space"> </span></p>
83 <p class="p10"><br></p>
84 <p class="p9">b.sine2(a.formant(12, 3).postln, a.geom(1.2), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
85 <p class="p10"><br></p>
86 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
87 <p class="p10"><br></p>
88 <p class="p9">y.free;</p>
89 <p class="p10"><br></p>
90 <p class="p3"><b>teeth(spacing, start)</b></p>
91 <p class="p2"><br></p>
92 <p class="p9">a.teeth(6, 3);<span class="Apple-converted-space"> </span></p>
93 <p class="p10"><br></p>
94 <p class="p9">b.sine2(a.teeth(2, 3).postln, a.geom(1.2), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
95 <p class="p10"><br></p>
96 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
97 <p class="p10"><br></p>
98 <p class="p9">b.sine2(a.teeth(4, 1).postln, a.geom(1.2), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
99 <p class="p9">b.sine2(a.teeth(1, 3).postln, a.geom(1.2), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
100 <p class="p9">b.sine2(a.teeth(2, 3).postln, a.geom(1.2), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
101 <p class="p10"><br></p>
102 <p class="p9">y.free;</p>
103 <p class="p10"><br></p>
104 <p class="p3"><b>cutoff(n) - </b>returns 1.0 to the nth place, fills the rest with 0.0</p>
105 <p class="p2"><br></p>
106 <p class="p9">a.cutoff(3);<span class="Apple-converted-space"> </span></p>
107 <p class="p10"><br></p>
108 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.cutoff(3), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
109 <p class="p10"><br></p>
110 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
111 <p class="p10"><br></p>
112 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.cutoff(3), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
113 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.cutoff(5), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
114 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.cutoff(1), <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
115 <p class="p10"><br></p>
116 <p class="p9">y.free;</p>
117 <p class="p10"><br></p>
118 <p class="p3"><b>shelf(start, end, startLevel, endLevel)<span class="Apple-converted-space"> </span></b></p>
119 <p class="p2"><br></p>
120 <p class="p9">a.shelf(0, 6, 1, 0);<span class="Apple-converted-space"> </span></p>
121 <p class="p10"><br></p>
122 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.shelf(0, 6, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
123 <p class="p10"><br></p>
124 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
125 <p class="p10"><br></p>
126 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.shelf(0, 11, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
127 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.shelf(2, 6, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
128 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.shelf(6, 8, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
129 <p class="p10"><br></p>
130 <p class="p9">y.free;</p>
131 <p class="p10"><br></p>
132 <p class="p3"><b>sine(wavelength, iphase, mul, add)<span class="Apple-converted-space"> </span></b></p>
133 <p class="p2"><br></p>
134 <p class="p9">a.sine(8, 0, 1, 0);<span class="Apple-converted-space"> </span></p>
135 <p class="p10"><br></p>
136 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.sine(8, 0, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
137 <p class="p10"><br></p>
138 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
139 <p class="p10"><br></p>
140 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.sine(4, 0, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
141 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.sine(2.2, 0.5pi, 0.4, 0.2).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
142 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.sine(pi, 0.25pi, 0.5, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
143 <p class="p10"><br></p>
144 <p class="p9">y.free;</p>
145 <p class="p10"><br></p>
146 <p class="p3"><b>pulse(wavelength, iphase, duty, mul, add)<span class="Apple-converted-space"> </span></b></p>
147 <p class="p2"><br></p>
148 <p class="p9">a.pulse(8, 0, 2, 1, 0);<span class="Apple-converted-space"> </span></p>
149 <p class="p10"><br></p>
150 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.pulse(8, 0, 2, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
151 <p class="p10"><br></p>
152 <p class="p9">y = z.play(s,[<span class="s4">\out</span>, 0, <span class="s4">\bufnum</span>, b]);<span class="Apple-converted-space"> </span></p>
153 <p class="p10"><br></p>
154 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.pulse(8, 0, 2, 1, 0).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
155 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.pulse(4, 0, 2, 0.4, 0.2).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
156 <p class="p9">b.sine2(a.ramp(1.0, 1.0), a.pulse(7, 0.5pi, 3, 0.5, 0.1).postln , <span class="s2">true</span>, <span class="s2">true</span>, <span class="s2">true</span>);</p>
157 <p class="p10"><br></p>
158 <p class="p9">y.free;</p>
159 <p class="p10"><br></p>
160 <p class="p3"><b>random methods:</b></p>
161 <p class="p2"><b></b><br></p>
162 <p class="p3"><b>rand(lo, hi)</b></p>
163 <p class="p3"><b>exprand(lo, hi)</b></p>
164 <p class="p3"><b>linrand(lo, hi)</b></p>
165 <p class="p3"><b>rand2(val)</b></p>
166 <p class="p3"><b>coin(prob)</b></p>
167 </body>
168 </html>