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: 9.0px Monaco
; min-height: 12.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #8f2116}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #007300}
16 span
.s1
{font: 18.0px Helvetica
}
17 span
.s2
{color: #0024f8}
18 span
.s3
{color: #002eaf}
19 span
.s4
{color: #0000bf}
20 span
.s5
{color: #000000}
21 span
.s6
{color: #007300}
22 span
.Apple-tab-span
{white-space:pre
}
26 <p class=
"p1"><span class=
"s1"><b>Pfuncn
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>function pattern of given length
</b></p>
27 <p class=
"p2"><br></p>
28 <p class=
"p1">superclass: Pattern
</p>
29 <p class=
"p2"><br></p>
30 <p class=
"p1"><b>Pfunc(func, repeats)
</b></p>
31 <p class=
"p2"><br></p>
32 <p class=
"p1">Returns a stream that returns values from the func.
</p>
33 <p class=
"p2"><br></p>
34 <p class=
"p1"><b>func
</b>- stream function
</p>
35 <p class=
"p1"><b>repeats
</b>-
<span class=
"Apple-converted-space"> </span>end after this number of times
</p>
36 <p class=
"p2"><br></p>
37 <p class=
"p1"><b>See also:
</b> <a href=
"Pfunc.html"><span class=
"s2">Pfunc
</span></a></p>
38 <p class=
"p2"><br></p>
39 <p class=
"p3"><br></p>
40 <p class=
"p4">// example
</p>
41 <p class=
"p3"><br></p>
43 <p class=
"p5"><span class=
"s3">var
</span> a, b, c;
</p>
44 <p class=
"p5">a =
<span class=
"s3">Pfuncn
</span>({ exprand(
0.1,
2.0) + #[
1,
2,
3,
6].choose },
2);
</p>
45 <p class=
"p5">b =
<span class=
"s3">Pfuncn
</span>({ #[-
2, -
3].choose },
2);
</p>
46 <p class=
"p5">Pseq([a, b], inf).asStream.nextN(
20).postln;
</p>
48 <p class=
"p3"><br></p>
49 <p class=
"p3"><br></p>
50 <p class=
"p4">// sound example
</p>
52 <p class=
"p6"><span class=
"s4">SynthDef
</span><span class=
"s5">(
</span>\help_sinegrain
<span class=
"s5">,
<span class=
"Apple-converted-space"> </span></span></p>
53 <p class=
"p5"><span class=
"Apple-tab-span"> </span>{
<span class=
"s4">arg
</span> out=
0, freq=
440, sustain=
0.05;
</p>
54 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> env;
</p>
55 <p class=
"p5"><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>
56 <p class=
"p5"><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>
57 <p class=
"p5"><span class=
"Apple-tab-span"> </span>}).add;
</p>
59 <p class=
"p3"><br></p>
60 <p class=
"p3"><br></p>
62 <p class=
"p5"><span class=
"s4">var
</span> a, b, c;
</p>
63 <p class=
"p5">a =
<span class=
"s4">Pfuncn
</span>({ exprand(
0.1,
2.0) + #[
1,
2,
3,
6].choose },
2);
</p>
64 <p class=
"p5">b =
<span class=
"s4">Pfuncn
</span>({ #[-
2, -
3].choose },
7);
</p>
65 <p class=
"p5">c =
<span class=
"s4">Pseq
</span>([a, b],
<span class=
"s4">inf
</span>).asStream;
</p>
67 <p class=
"p5"><span class=
"Apple-tab-span"> </span>c.do {
<span class=
"s4">|val|
</span></p>
68 <p class=
"p5"><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>, val *
100 +
300]);
</p>
69 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.02.wait;
</p>
70 <p class=
"p5"><span class=
"Apple-tab-span"> </span>}
</p>
71 <p class=
"p5">}.fork;
</p>
73 <p class=
"p3"><br></p>
74 <p class=
"p3"><br></p>