1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.42">
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: 18.0px Helvetica
; min-height: 22.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #a71e12; min-height: 12.0px}
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
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0019b7}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
20 span
.s1
{color: #0019b7}
21 span
.s2
{color: #606060}
22 span
.s3
{color: #000000}
23 span
.Apple-tab-span
{white-space:pre
}
27 <p class=
"p1"><b>NRand
</b></p>
28 <p class=
"p2"><br></p>
29 <p class=
"p3"><b>NRand(lo, hi, n)
</b></p>
30 <p class=
"p4"><br></p>
31 <p class=
"p3">Generates a single random float value in a sum of n uniform distributions from lo to hi.
</p>
32 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
33 <p class=
"p3">n =
1 : uniform distribution - same as Rand
</p>
34 <p class=
"p3">n =
2 : triangular distribution
</p>
35 <p class=
"p3">n =
3 : smooth hump
</p>
36 <p class=
"p3">as n increases, distribution converges towards gaussian
</p>
37 <p class=
"p6"><br></p>
39 <p class=
"p7"><span class=
"s1">SynthDef
</span>(
<span class=
"s2">"help-NRand"</span>, {
<span class=
"s1">arg
</span> out=
0, n=
0;
</p>
40 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(out,
<span class=
"Apple-converted-space"> </span></p>
41 <p class=
"p8"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>FSinOsc
<span class=
"s3">.ar(
</span></p>
42 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1"><span class=
"Apple-tab-span"> </span>NRan
</span>d(
1200.0,
4000.0, n),
<span class=
"Apple-converted-space"> </span></p>
43 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
<span class=
"s1">Line
</span>.kr(
0.2,
0,
0.01, doneAction:
2))
</p>
44 <p class=
"p7"><span class=
"Apple-tab-span"> </span>)
</p>
45 <p class=
"p7">}).send(s);
</p>
47 <p class=
"p9"><br></p>
49 <p class=
"p7">n =
0;
</p>
50 <p class=
"p7">Routine({
</p>
51 <p class=
"p7"><span class=
"Apple-tab-span"> </span>inf.do({ arg i;
</p>
52 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s1">Synth
</span><span class=
"s3">.new(
</span>"help-NRand", [\n, n]
<span class=
"s3">);
0.05.wait;
</span></p>
53 <p class=
"p7"><span class=
"Apple-tab-span"> </span>})
</p>
54 <p class=
"p7">}).play;
</p>
56 <p class=
"p9"><br></p>
57 <p class=
"p7">n =
1;
</p>
58 <p class=
"p7">n =
2;
</p>
59 <p class=
"p7">n =
4;
</p>