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=
"1038.25">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.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
; color: #0000ee}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #90241c}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #486b1c}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #002cb2}
18 span
.s1
{font: 18.0px Helvetica
}
19 span
.s2
{color: #000000}
20 span
.s3
{text-decoration: underline
}
21 span
.s4
{color: #002cb2}
22 span
.s5
{color: #606060}
23 span
.s6
{color: #486b1c}
24 span
.Apple-tab-span
{white-space:pre
}
28 <p class=
"p1"><span class=
"s1"><b>Pbrown
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>brownian motion pattern
</b></p>
29 <p class=
"p2"><br></p>
30 <p class=
"p1">superclass: Pattern
</p>
31 <p class=
"p2"><br></p>
32 <p class=
"p1"><b>Pbrown(lo, hi, step, length)
</b></p>
33 <p class=
"p2"><br></p>
34 <p class=
"p1">Returns a stream that behaves like a brownian motion.
<span class=
"Apple-converted-space"> </span></p>
35 <p class=
"p2"><br></p>
36 <p class=
"p1"><b>lo, hi
</b> - lower and upper boundary of values
<span class=
"Apple-converted-space"> </span>(default:
0.0 and
1.0)
</p>
37 <p class=
"p1"><b>step
</b> - maximum change per step - the distribution is xrand2.
<span class=
"Apple-converted-space"> </span>(default:
0.125)
</p>
38 <p class=
"p1"><b>length
</b> - number of values produced (default: inf)
</p>
39 <p class=
"p2"><br></p>
40 <p class=
"p2"><br></p>
41 <p class=
"p3"><span class=
"s2"><b>See also:
</b> <a href=
"../../UGens/Noise/BrownNoise.html"><span class=
"s3">BrownNoise
</span></a>,
<a href=
"Pgbrown.html"><span class=
"s3">Pgbrown
</span></a></span></p>
42 <p class=
"p2"><br></p>
43 <p class=
"p4"><br></p>
44 <p class=
"p5">// example
</p>
45 <p class=
"p4"><br></p>
47 <p class=
"p6"><span class=
"s4">var
</span> a;
</p>
48 <p class=
"p6">a =
<span class=
"s4">Pbrown
</span>(
0.0,
1.0,
0.1,
<span class=
"s4">inf
</span>);
</p>
49 <p class=
"p6">c = a.asStream.nextN(
500);
</p>
50 <p class=
"p6">w =
<span class=
"s4">Window
</span>.new(
<span class=
"s5">"Pbrown"</span>,
<span class=
"s4">Rect
</span>(
10,
10,
540,
800));
</p>
51 <p class=
"p5">// plot the values
</p>
52 <p class=
"p6">c.plot(bounds:
<span class=
"s4">Rect
</span>(
10,
10,
520,
380), discrete:
<span class=
"s4">true
</span>, parent: w);
</p>
53 <p class=
"p5">// a histogram of the values
</p>
54 <p class=
"p6">c.histo(
500).plot(bounds:
<span class=
"s4">Rect
</span>(
10,
410,
520,
380), parent: w);
</p>
56 <p class=
"p4"><br></p>
58 <p class=
"p6"><span class=
"s4">var
</span> a;
</p>
59 <p class=
"p6">a =
<span class=
"s4">Pbrown
</span>(
0.0,
1.0,
0.2,
<span class=
"s4">inf
</span>);
</p>
60 <p class=
"p6">a.asStream.nextN(
1000).plot;
</p>
62 <p class=
"p4"><br></p>
63 <p class=
"p4"><br></p>
64 <p class=
"p5">// sound example
</p>
66 <p class=
"p7"><span class=
"s4">SynthDef
</span><span class=
"s2">(
</span>\help_sinegrain
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
67 <p class=
"p6"><span class=
"Apple-tab-span"> </span>{
<span class=
"s4">arg
</span> out=
0, freq=
440, sustain=
0.05;
</p>
68 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> env;
</p>
69 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>env =
<span class=
"s4">EnvGen
</span>.kr(
<span class=
"s4">Env
</span>.perc(
0.01, sustain,
0.2), doneAction:
2);
</p>
70 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Out
</span>.ar(out,
<span class=
"s4">SinOsc
</span>.ar(freq,
0, env))
</p>
71 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}).add;
</p>
73 <p class=
"p4"><br></p>
74 <p class=
"p4"><br></p>
76 <p class=
"p6"><span class=
"s4">var
</span> a;
</p>
77 <p class=
"p6">a =
<span class=
"s4">Pbrown
</span>(
0.0,
1.0,
0.1,
<span class=
"s4">inf
</span>).asStream;
</p>
79 <p class=
"p6"><span class=
"Apple-tab-span"> </span>loop {
</p>
80 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Synth
</span>(
<span class=
"s6">\help_sinegrain
</span>, [
<span class=
"s6">\freq
</span>, a.next *
600 +
300]);
</p>
81 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.02.wait;
</p>
82 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}
</p>
83 <p class=
"p6">}.fork;
</p>
85 <p class=
"p4"><br></p>
86 <p class=
"p4"><br></p>
87 <p class=
"p4"><br></p>
88 <p class=
"p5">// parallel browninan motions
</p>
90 <p class=
"p6"><span class=
"s4">var
</span> a, x, f;
</p>
91 <p class=
"p6">a =
<span class=
"s4">Pbrown
</span>(
0.0,
1.0,
0.1,
<span class=
"s4">inf
</span>);
</p>
92 <p class=
"p4"><br></p>
93 <p class=
"p8"><span class=
"s2">f = {
</span>|pattern, dt=
0.02, min=
300, max=
900|
</p>
94 <p class=
"p6"><span class=
"Apple-tab-span"> </span>{
</p>
95 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> x = pattern.asStream;
</p>
96 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>loop {
</p>
97 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Synth
</span>.grain(
<span class=
"s6">\help_sinegrain
</span>, [
<span class=
"s6">\freq
</span>, x.next.linexp(
0,
1, min, max),
<span class=
"s6">\sustain
</span>, dt]);
</p>
98 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>dt.wait;
</p>
99 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}
</p>
100 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}.fork;
</p>
101 <p class=
"p6">}.flop;
</p>
102 <p class=
"p4"><br></p>
103 <p class=
"p5">//
3 parallel motions
</p>
104 <p class=
"p6">f.(a, [
0.02,
0.08,
0.16]);
</p>
106 <p class=
"p4"><br></p>
107 <p class=
"p4"><br></p>
108 <p class=
"p4"><br></p>
109 <p class=
"p4"><br></p>