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=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Helvetica
; min-height: 18.0px}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Helvetica
}
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: 12.0px Helvetica
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
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: #001bb9}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #2c7014}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #001bb9; min-height: 12.0px}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
21 span
.s1
{color: #001bb9}
22 span
.s2
{color: #000000}
23 span
.s3
{color: #2c7014}
24 span
.Apple-tab-span
{white-space:pre
}
28 <p class=
"p1"><br></p>
29 <p class=
"p2"><b>Recursive phrases and granular composite sounds
</b></p>
30 <p class=
"p3"><br></p>
31 <p class=
"p3"><br></p>
32 <p class=
"p4">Pdef can be used as a global storage for event patterns. Here a way is provided by which these
</p>
33 <p class=
"p4">definitions can be used as an instrument that consists of several events (a
<i>phrase
</i>),
<span class=
"Apple-converted-space"> </span></p>
34 <p class=
"p4">such as a cloud of short grains. Furthermore, this scheme can be applied recursively, so that structures like a cloud of clouds can be constructed.
</p>
35 <p class=
"p5"><br></p>
36 <p class=
"p4">when the event type
<b>\phrase
</b> is passed in, the event looks for a pattern in
<b>Pdef.all
</b> if it can find a definition
</p>
37 <p class=
"p4"><span class=
"Apple-converted-space"> </span>- if it finds one it plays this pattern in the context of the outer pattern's event.
</p>
38 <p class=
"p4"><span class=
"Apple-converted-space"> </span>If there is no definition to be found there, it uses a SynthDef with this name, if present.
</p>
39 <p class=
"p5"><span class=
"Apple-converted-space"> </span></p>
40 <p class=
"p4"><span class=
"Apple-converted-space"> </span>When passing a
<i>function
</i> to Pdef it creates a PlazyEnvir internally.
</p>
41 <p class=
"p4"><span class=
"Apple-converted-space"> </span>Its function is evaluated in the context of the outer environment (see
<a href=
"../../../Streams-Patterns-Events/Patterns/PlazyEnvir.html"><span class=
"s1">PlazyEnvir
</span></a> ) which should return
</p>
42 <p class=
"p4"><span class=
"Apple-converted-space"> </span>a pattern or a stream.
</p>
43 <p class=
"p3"><br></p>
44 <p class=
"p3"><br></p>
46 <p class=
"p6">s.boot;
</p>
47 <p class=
"p3"><br></p>
48 <p class=
"p7">SynthDef
<span class=
"s2">(
</span><span class=
"s3">\pgrain
</span><span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
49 <p class=
"p6"><span class=
"Apple-tab-span"> </span>{
<span class=
"s1">arg
</span> out =
0, freq=
800, sustain=
0.001, amp=
0.5, pan =
0;
</p>
50 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> window;
</p>
51 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>window =
<span class=
"s1">Env
</span>.sine(sustain, amp *
<span class=
"s1">AmpCompA
</span>.kr(freq));
</p>
52 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(out,
<span class=
"Apple-converted-space"> </span></p>
53 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">Pan2
</span>.ar(
</p>
54 <p class=
"p6"><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=
"s1">SinOsc
</span>.ar(freq),
</p>
55 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>pan
</p>
56 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>) *
<span class=
"s1">EnvGen
</span>.ar(window, doneAction:
2)
</p>
57 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
58 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}
</p>
59 <p class=
"p6">).store;
</p>
60 <p class=
"p3"><br></p>
61 <p class=
"p8"><span class=
"s1">SynthDef
</span><span class=
"s2">(
</span>\noiseGrain
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
62 <p class=
"p6"><span class=
"Apple-tab-span"> </span>{
<span class=
"s1">arg
</span> out =
0, freq=
800, sustain=
0.001, amp=
0.5, pan =
0;
</p>
63 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> window;
</p>
64 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>window =
<span class=
"s1">Env
</span>.perc(
0.002, sustain, amp *
<span class=
"s1">AmpCompA
</span>.kr(freq));
</p>
65 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(out,
<span class=
"Apple-converted-space"> </span></p>
66 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">Pan2
</span>.ar(
</p>
67 <p class=
"p6"><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=
"s1">Ringz
</span>.ar(
<span class=
"s1">PinkNoise
</span>.ar(
0.1), freq,
2.6),
</p>
68 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>pan
</p>
69 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>) *
<span class=
"s1">EnvGen
</span>.ar(window, doneAction:
2)
</p>
70 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
71 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}
</p>
72 <p class=
"p6">).store;
</p>
73 <p class=
"p3"><br></p>
74 <p class=
"p3"><br></p>
75 <p class=
"p3"><br></p>
76 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep
</span>, {
<span class=
"s1">arg
</span> sustain=
1, n=
8, freq=
440, ratio=
0.1;
</p>
77 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
78 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
79 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, sustain.value / n,
</p>
80 <p class=
"p9"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s3">\freq
</span><span class=
"s2">,
</span><span class=
"s1">Pseq
</span><span class=
"s2">((
1..n))
<span class=
"Apple-converted-space"> </span>* ratio +
1 * freq.value
</span>// freq is a function, has to be evaluated
<span class=
"Apple-converted-space"> </span></p>
81 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
83 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep2
</span>, {
<span class=
"s1">arg
</span> sustain=
1, n=
8, freq=
440, ratio=
0.1;
</p>
84 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
85 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\noiseGrain
<span class=
"s2">,
</span></p>
86 <p class=
"p9"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s3">\dur
</span><span class=
"s2">, sustain.value / n,
<span class=
"Apple-converted-space"> </span></span>// sustain is also a function, has to be evaluated
<span class=
"Apple-converted-space"> </span></p>
87 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\freq
</span>,
<span class=
"s1">Pseq
</span>((
1..n).scramble) * ratio +
1 * freq.value,
</p>
88 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
2</span></p>
89 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
91 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep3
</span>, {
<span class=
"s1">arg
</span> freq=
440;
</p>
92 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
93 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
94 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
95 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\freq
</span>,
<span class=
"s1">Pfunc
</span>({ rrand(
0.8,
1.3)
<span class=
"Apple-converted-space"> </span>})
<span class=
"Apple-converted-space"> </span>* freq.value,
</p>
96 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
0.3,
</p>
97 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
1.3,
</p>
98 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
5</p>
99 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
100 <p class=
"p6">});
</p>
102 <p class=
"p3"><br></p>
103 <p class=
"p3"><br></p>
104 <p class=
"p3"><br></p>
105 <p class=
"p3"><br></p>
106 <p class=
"p9">// the pattern that is found in Pdef.all (or your own defined library) is truncated in time
</p>
107 <p class=
"p9">// using the sustain provided by the outer pattern.
</p>
109 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
110 <p class=
"p9"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span><span class=
"s3">\type
</span><span class=
"s2">,
</span><span class=
"s3">\phrase
</span><span class=
"s2">,
</span>// phrase event from global library
</p>
111 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
112 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
15,
</p>
113 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
4,
6,
3],
<span class=
"s1">inf
</span>),
</p>
114 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\sustain
</span>,
<span class=
"s1">Pseq
</span>([
1.3,
0.2,
0.4],
<span class=
"s1">inf
</span>)
</p>
115 <p class=
"p6">).play
</p>
117 <p class=
"p3"><br></p>
118 <p class=
"p9">// multichannel expansion is propagated into the subpatterns
</p>
120 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
121 <p class=
"p9"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span><span class=
"s3">\type
</span><span class=
"s2">,
</span><span class=
"s3">\phrase
</span><span class=
"s2">,
</span>// phrase event from global library
</p>
122 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
123 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
15,
</p>
124 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
0,
6,
3],
<span class=
"s1">inf
</span>) +
<span class=
"s1">Prand
</span>([
0, [
0,
3], [
0,
5], [
0,
15]],
<span class=
"s1">inf
</span>),
</p>
125 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\ratio
</span>,
<span class=
"s1">Prand
</span>([
0.1,
0.1, [
0.1, -
0.1] ],
<span class=
"s1">inf
</span>)
</p>
126 <p class=
"p6">).play
</p>
128 <p class=
"p3"><br></p>
129 <p class=
"p9">// various instruments and synthdefs can be used on the same level
</p>
131 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
132 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
133 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span><span class=
"s1">Pseq
</span><span class=
"s2">([
</span>\sweep
<span class=
"s2">,
</span>\default
<span class=
"s2">,
</span>\sweep2
<span class=
"s2">,
</span>\sweep3
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">],
</span><span class=
"s1">inf
</span><span class=
"s2">),
</span></p>
134 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
3,
2],
<span class=
"s1">inf
</span>),
</p>
135 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
<span class=
"s1">Pseq
</span>([
1,
0.5],
<span class=
"s1">inf
</span>) *
0.7,
</p>
136 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
<span class=
"s1">Pseq
</span>([
4,
6,
25,
10],
<span class=
"s1">inf
</span>),
</p>
137 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\ratio
</span>,
<span class=
"s1">Prand
</span>([
0.03,
0.1,
0.4, -
0.1],
<span class=
"s1">inf
</span>) +
<span class=
"s1">Pseq
</span>([
0,
0, [
0,
0.02]],
<span class=
"s1">inf
</span>),
</p>
138 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>(#[
0.5,
1,
0.5,
0.1,
0.1],
<span class=
"s1">inf
</span>)
</p>
139 <p class=
"p6">).play;
</p>
141 <p class=
"p3"><br></p>
142 <p class=
"p3"><br></p>
143 <p class=
"p9">//////// of course also a patten can be used directly in a Pdef
<span class=
"Apple-converted-space"> </span></p>
144 <p class=
"p3"><br></p>
146 <p class=
"p8"><span class=
"s1">Pdef
</span><span class=
"s2">(
</span>\sweep
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
147 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
148 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span><span class=
"s1">Pseq
</span><span class=
"s2">([
</span>\pgrain
<span class=
"s2">,
</span>\noiseGrain
<span class=
"s2">],
</span><span class=
"s1">inf
</span><span class=
"s2">),
</span></p>
149 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
<span class=
"s1">Pseq
</span>([
1,
2,
1,
3,
1,
4,
1,
5]) *
0.05,
</p>
150 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Prand
</span>([
0.5,
0.5,
3],
<span class=
"s1">inf
</span>)
<span class=
"Apple-tab-span"> </span></p>
151 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
<span class=
"Apple-tab-span"> </span></p>
154 <p class=
"p3"><br></p>
155 <p class=
"p9">// play directly, emebdded in stream (see Pdef.help)
</p>
156 <p class=
"p10"><br></p>
157 <p class=
"p6"><span class=
"s1">Pn
</span>(
<span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep
</span>),
2).play;
</p>
158 <p class=
"p9"><span class=
"s1">Pdef
</span><span class=
"s2">(
</span><span class=
"s3">\sweep
</span><span class=
"s2">).fork;
</span>// play without changing player state (see Pdef.help)
</p>
159 <p class=
"p3"><br></p>
160 <p class=
"p3"><br></p>
161 <p class=
"p9">// play within a pattern
</p>
163 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
164 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
165 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
166 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
1b,
4,
2,
3,
1b],
<span class=
"s1">inf
</span>),
</p>
167 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\pan
</span>,
<span class=
"s1">Pfunc
</span>(#{
1.0.rand2 })
</p>
168 <p class=
"p6">).play
</p>
170 <p class=
"p3"><br></p>
171 <p class=
"p3"><br></p>
172 <p class=
"p3"><br></p>
173 <p class=
"p9">//////// recursion examples //////////
</p>
174 <p class=
"p3"><br></p>
175 <p class=
"p9">// the given pattern can be recursively applied to itself
<span class=
"Apple-converted-space"> </span></p>
176 <p class=
"p9">// resulting in selfsimilar sound structures, like lindenmeyer systems (see also Prewrite)
</p>
177 <p class=
"p9">// special care is taken so that no infinite loops can happen.
</p>
178 <p class=
"p9">// just like with non recursive phrasing, new values override old values,
<span class=
"Apple-converted-space"> </span></p>
179 <p class=
"p9">// any values that are not provided within the pattern definition
<span class=
"Apple-converted-space"> </span></p>
180 <p class=
"p9">// are passed in from the outer event.
</p>
181 <p class=
"p3"><br></p>
182 <p class=
"p3"><br></p>
183 <p class=
"p3"><br></p>
185 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep
</span>, {
<span class=
"s1">arg
</span> dur=
1, n=
4, freq=
440, ratio=
0.3;
</p>
186 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
187 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
188 <p class=
"p9"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s3">\dur
</span><span class=
"s2">, dur.value / n,
<span class=
"Apple-tab-span"> </span></span>// now dur is dependant on outer dur.
</p>
189 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\freq
</span>,
<span class=
"s1">Pseries
</span>(
1,
1,
<span class=
"s1">inf
</span>) * ratio +
1 * freq.value %
17000</p>
190 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
191 <p class=
"p6">});
</p>
193 <p class=
"p3"><br></p>
194 <p class=
"p3"><br></p>
195 <p class=
"p9">// no recursion
</p>
197 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
198 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
199 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
200 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>((
0.
.5),
<span class=
"s1">inf
</span>)
</p>
201 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play;
</p>
203 <p class=
"p3"><br></p>
204 <p class=
"p9">// no recursion, with legato
> 1.0 and varying notes
</p>
205 <p class=
"p9">// note how subpatterns are truncated to note length
<span class=
"Apple-converted-space"> </span></p>
206 <p class=
"p9">// provided by outer pattern (in this case determined by legato)
</p>
208 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
209 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
210 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
211 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>((
0.
.5),
<span class=
"s1">inf
</span>),
</p>
212 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>([
1.2,
2.8,
0.3],
<span class=
"s1">inf
</span>)
</p>
213 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play;
</p>
215 <p class=
"p3"><br></p>
216 <p class=
"p9">// to block the proliferation of \legato into the phrase, set \transparency to
0</p>
218 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
219 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
220 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
221 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\transparency
<span class=
"s2">,
0,
</span></p>
222 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>((
0.
.5),
<span class=
"s1">inf
</span>),
</p>
223 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>([
1.2,
2.8,
0.3],
<span class=
"s1">inf
</span>)
</p>
224 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play;
</p>
226 <p class=
"p3"><br></p>
227 <p class=
"p3"><br></p>
228 <p class=
"p9">// recursion over one level
</p>
230 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
231 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
232 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
233 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
1,
2,
3],
<span class=
"s1">inf
</span>),
</p>
234 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
1</span></p>
235 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
237 <p class=
"p3"><br></p>
238 <p class=
"p9">// recursion over one level: legato is recursively applied
</p>
240 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
241 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
242 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
243 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
1,
2,
3],
<span class=
"s1">inf
</span>),
</p>
244 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>([
0.5,
1,
1.5,
1.8],
<span class=
"s1">inf
</span>),
</p>
245 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
1</span></p>
246 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
248 <p class=
"p3"><br></p>
249 <p class=
"p9">// to block the proliferation of properties such as \legato and \degree
</p>
250 <p class=
"p9">// into the phrase, set \transparency to
0.
</p>
252 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
253 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
254 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
255 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
1,
2,
3],
<span class=
"s1">inf
</span>),
</p>
256 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>([
0.5,
1,
1.5,
1.8],
<span class=
"s1">inf
</span>),
</p>
257 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
1,
</span></p>
258 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\transparency
<span class=
"s2">,
0</span></p>
259 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
261 <p class=
"p3"><br></p>
262 <p class=
"p9">// recursion over
3 levels: legato is recursively applied
</p>
264 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
265 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
266 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
267 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\degree
<span class=
"s2">,
</span><span class=
"s1">1</span><span class=
"s2">,
</span></p>
268 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>([
0.5,
1,
1.3],
<span class=
"s1">inf
</span>),
</p>
269 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
3,
</span></p>
270 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
3</p>
271 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
273 <p class=
"p3"><br></p>
274 <p class=
"p9">// to block the proliferation of \legato into the phrase, set \transparency to a level at which
</p>
275 <p class=
"p9">// to stop passing the value.
</p>
277 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
278 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
279 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
280 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\degree
<span class=
"s2">,
1,
</span></p>
281 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>([
0.5,
1,
2.3],
<span class=
"s1">inf
</span>),
</p>
282 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
3,
</span></p>
283 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
3,
</p>
284 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\transparency
</span>,
<span class=
"s1">Pstutter
</span>(
8,
<span class=
"s1">Prand
</span>([
0,
1,
2],
<span class=
"s1">inf
</span>))
</p>
285 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
287 <p class=
"p3"><br></p>
288 <p class=
"p3"><br></p>
289 <p class=
"p3"><br></p>
290 <p class=
"p9">// to modify this recursion, assign values explicitly:
</p>
292 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep
</span>, {
<span class=
"s1">arg
</span> dur=
1, n=
4, ratio=
0.5, freq=
440;
</p>
293 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> legato;
</p>
294 <p class=
"p6"><span class=
"Apple-tab-span"> </span>freq = freq.value;
</p>
295 <p class=
"p6"><span class=
"Apple-tab-span"> </span>legato = freq %
200 /
200 *
3 +
0.2;
</p>
296 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
297 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
298 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, dur.value / n,
</p>
299 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>, legato,
</p>
300 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\freq
</span>,
<span class=
"s1">Pseq
</span>((
1..n) * ratio +
1 * freq)
</p>
301 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
302 <p class=
"p6">});
</p>
304 <p class=
"p3"><br></p>
305 <p class=
"p9">// recursion over one level: degree is assigned to each phrase,
</p>
306 <p class=
"p9">// because freq is calculated internally and overrides degree on the second level
</p>
308 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
309 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
310 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
311 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>((
0.
.10),
<span class=
"s1">inf
</span>),
</p>
312 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
1</span></p>
313 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
315 <p class=
"p3"><br></p>
316 <p class=
"p3"><br></p>
317 <p class=
"p3"><br></p>
318 <p class=
"p9">// recursion over two levels
</p>
320 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
321 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
322 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
323 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\degree
<span class=
"s2">,
0,
</span></p>
324 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
2</span></p>
325 <p class=
"p6">).play
</p>
327 <p class=
"p3"><br></p>
328 <p class=
"p9">// recursion over three levels with variable number of grains
</p>
330 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
331 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
332 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
333 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\degree
<span class=
"s2">, -
5,
</span></p>
334 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
<span class=
"s1">Pseq
</span>([
1,
2,
3],
<span class=
"s1">inf
</span>),
</p>
335 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
3</span></p>
336 <p class=
"p6">).play
</p>
338 <p class=
"p3"><br></p>
339 <p class=
"p3"><br></p>
340 <p class=
"p9">//
"zoom" in
</p>
341 <p class=
"p6"><span class=
"s1">TempoClock
</span>.default.tempo =
0.2;
</p>
342 <p class=
"p6"><span class=
"s1">TempoClock
</span>.default.tempo =
1.0;
</p>
343 <p class=
"p3"><br></p>
344 <p class=
"p3"><br></p>
345 <p class=
"p9">// recursion over variable levels
</p>
347 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
348 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
349 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
350 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
<span class=
"s1">Prand
</span>([
2,
7,
3],
<span class=
"s1">inf
</span>),
</p>
351 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\degree
<span class=
"s2">, -
5,
</span></p>
352 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\recursionLevel
</span>,
<span class=
"s1">Prand
</span>([
0,
1,
2],
<span class=
"s1">inf
</span>)
</p>
353 <p class=
"p6">).play
</p>
355 <p class=
"p3"><br></p>
356 <p class=
"p3"><br></p>
357 <p class=
"p3"><br></p>
358 <p class=
"p9">// replace the frequency based pattern with a degree based pattern
</p>
360 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep
</span>, {
<span class=
"s1">arg
</span> sustain=
1, n=
8, degree=
0, ratio=
1;
</p>
361 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
362 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
363 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, sustain.value / n,
</p>
364 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>((
1..n)) * ratio +
1 + degree.value
</p>
365 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
366 <p class=
"p6">});
</p>
368 <p class=
"p3"><br></p>
369 <p class=
"p3"><br></p>
370 <p class=
"p9">// drunken master
</p>
372 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
373 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
374 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
375 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
<span class=
"s1">Prand
</span>([
2,
4,
3,
8],
<span class=
"s1">inf
</span>),
</p>
376 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([-
5,
0, -
2],
<span class=
"s1">inf
</span>),
</p>
377 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
<span class=
"s1">Pseq
</span>([
1.4,
0.5,
2],
<span class=
"s1">inf
</span>),
</p>
378 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\scale
</span>, #[
0,
2,
5,
7,
10],
</p>
379 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\recursionLevel
</span>,
<span class=
"s1">Prand
</span>([
0,
1,
2],
<span class=
"s1">inf
</span>)
</p>
380 <p class=
"p6">).play
</p>
382 <p class=
"p3"><br></p>
383 <p class=
"p3"><br></p>
385 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
386 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
387 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
388 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\synthDef
<span class=
"s2">,
</span><span class=
"s1">Prand
</span><span class=
"s2">([
</span>\pgrain
<span class=
"s2">,
</span>\default
<span class=
"s2">,
</span>\noiseGrain
<span class=
"s2">],
</span><span class=
"s1">inf
</span><span class=
"s2">),
</span></p>
389 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
<span class=
"s1">Prand
</span>([
2,
4,
3,
8],
<span class=
"s1">inf
</span>),
</p>
390 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([-
5,
0, -
2],
<span class=
"s1">inf
</span>),
</p>
391 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
</span><span class=
"s1">Prand
</span><span class=
"s2">([
0,
1],
</span><span class=
"s1">inf
</span><span class=
"s2">)
</span></p>
392 <p class=
"p6">).play
</p>
394 <p class=
"p3"><br></p>
395 <p class=
"p3"><br></p>
396 <p class=
"p9">// use a different parent event in the inner pattern
</p>
398 <p class=
"p6">e =
<span class=
"s1">Event
</span>.default;
</p>
399 <p class=
"p6">e.use { ~sustain = {
2.0.exprand(
0.05) } };
</p>
400 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep
</span>, {
<span class=
"s1">arg
</span> sustain=
1, n=
8, degree=
0, ratio=
1;
</p>
401 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
402 <p class=
"p9"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s3">\parent
</span><span class=
"s2">, e,
</span>// replace by some other event
</p>
403 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
404 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, sustain.value / n,
</p>
405 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>((
1..n)) * ratio +
1 + degree.value
</p>
406 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
407 <p class=
"p6">});
</p>
409 <p class=
"p3"><br></p>
410 <p class=
"p3"><br></p>
412 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
413 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
414 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
415 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
<span class=
"s1">Prand
</span>([
2,
4,
3,
8],
<span class=
"s1">inf
</span>),
</p>
416 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([-
5,
0, -
2],
<span class=
"s1">inf
</span>),
</p>
417 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
</span><span class=
"s1">Prand
</span><span class=
"s2">([
0,
1],
</span><span class=
"s1">inf
</span><span class=
"s2">)
</span></p>
418 <p class=
"p6">).play
</p>
420 <p class=
"p3"><br></p>
421 <p class=
"p3"><br></p>
422 <p class=
"p9">// pass in a pattern from outside
</p>
423 <p class=
"p3"><br></p>
425 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep
</span>, {
<span class=
"s1">arg
</span> sustain=
1, n=
8, degree=
0, ratio=
1;
</p>
426 <p class=
"p6"><span class=
"Apple-tab-span"> </span>n = n.value;
</p>
427 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
428 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
429 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, sustain.value / n,
</p>
430 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
1,
2,
3,
4,
5 ] * ratio +
1 + degree.value)
<span class=
"Apple-tab-span"> </span>)
</p>
431 <p class=
"p6">});
</p>
433 <p class=
"p3"><br></p>
434 <p class=
"p3"><br></p>
436 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
437 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
438 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
439 <p class=
"p9"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span><span class=
"s3">\n
</span><span class=
"s2">, {
</span><span class=
"s1">Pshuf
</span><span class=
"s2">([
2,
4,
3,
8,
16,
32],
</span><span class=
"s1">inf
</span><span class=
"s2">) },
</span>//
<span class=
"Apple-converted-space"> </span>use a function to insulate from embedInStream
</p>
440 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([-
5,
0, -
2],
<span class=
"s1">inf
</span>),
</p>
441 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
</span><span class=
"s1">Prand
</span><span class=
"s2">([
0,
1],
</span><span class=
"s1">inf
</span><span class=
"s2">)
</span></p>
442 <p class=
"p6">).play
</p>
444 <p class=
"p3"><br></p>
445 <p class=
"p3"><br></p>
446 <p class=
"p3"><br></p>
447 <p class=
"p3"><br></p>
448 <p class=
"p9">// recursion inside the pattern definition
</p>
449 <p class=
"p3"><br></p>
451 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\sweep2
</span>, {
<span class=
"s1">arg
</span> sustain=
1, n=
2, degree=
0, ratio=
1;
</p>
452 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
453 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
454 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
455 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, sustain.value / n,
</p>
456 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>((
1.
.5).scramble * ratio +
1 + degree.value),
</p>
457 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
2</span></p>
458 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
459 <p class=
"p6">});
</p>
461 <p class=
"p3"><br></p>
463 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
464 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
465 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep2
<span class=
"s2">,
</span></p>
466 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
3,
</p>
467 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([-
5,
0, -
2],
<span class=
"s1">inf
</span>)
</p>
468 <p class=
"p6">).play
</p>
470 <p class=
"p3"><br></p>
471 <p class=
"p3"><br></p>
472 <p class=
"p9">// instruments do not crossfade while they play (to make phrasing more efficient).
</p>
473 <p class=
"p3"><br></p>
474 <p class=
"p3"><br></p>
476 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
477 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
478 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\sweep
<span class=
"s2">,
</span></p>
479 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
3,
</p>
480 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>,
<span class=
"s1">Pseq
</span>([
0,
2b,
3,
4],
<span class=
"s1">inf
</span>),
</p>
481 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
2,
</p>
482 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\legato
<span class=
"s2">,
2</span></p>
483 <p class=
"p6">).play
</p>
485 <p class=
"p3"><br></p>
486 <p class=
"p9">// change pattern definition while playing:
</p>
488 <p class=
"p8"><span class=
"s1">Pdef
</span><span class=
"s2">(
</span>\sweep
<span class=
"s2">,
</span></p>
489 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
490 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
491 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, exprand(
0.01,
0.1),
</p>
492 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>, rrand(
0.01,
2.0),
</p>
493 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\octave
</span>, rrand(
5,
7)
</p>
494 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
497 <p class=
"p3"><br></p>
498 <p class=
"p3"><br></p>
499 <p class=
"p9">// koch
"snowflake"</p>
501 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\koch
</span>, {
<span class=
"s1">arg
</span> dur=
1, freq=
440;
</p>
502 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
503 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, dur.value /
3,
</p>
504 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\freq
</span>, freq.value *
<span class=
"s1">Pseq
</span>([
1,
1.2,
1])
</p>
505 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
506 <p class=
"p6">});
</p>
508 <p class=
"p3"><br></p>
510 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
511 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
<span class=
"Apple-converted-space"> </span></span></p>
512 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\koch
<span class=
"s2">,
</span></p>
513 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\synthDef
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
514 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
9,
</p>
515 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
2,
</span></p>
516 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
1.1</p>
517 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
519 <p class=
"p3"><br></p>
521 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
522 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
523 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\koch
<span class=
"s2">,
</span></p>
524 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\synthDef
<span class=
"s2">,
</span>\pgrain
<span class=
"s2">,
</span></p>
525 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
9,
</p>
526 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
4,
</span></p>
527 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
1.1</p>
528 <p class=
"p6"><span class=
"Apple-tab-span"> </span>).play
</p>
530 <p class=
"p3"><br></p>
532 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\koch
</span>, {
<span class=
"s1">arg
</span> dur=
1, degree=
0;
</p>
533 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
534 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, dur.value /
3,
</p>
535 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\degree
</span>, degree +
<span class=
"s1">Pseq
</span>([
0,
2,
0])
</p>
536 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
537 <p class=
"p6">});
</p>
539 <p class=
"p3"><br></p>
540 <p class=
"p3"><br></p>
541 <p class=
"p3"><br></p>
542 <p class=
"p3"><br></p>
543 <p class=
"p3"><br></p>
544 <p class=
"p9">// soundfile example
</p>
545 <p class=
"p3"><br></p>
546 <p class=
"p3"><br></p>
548 <p class=
"p6"><span class=
"s1">SynthDef
</span>(
<span class=
"s3">\play_from_to
</span>, {
<span class=
"s1">arg
</span> out, bufnum, from=
0.0, to=
1.0, sustain=
1.0;
</p>
549 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> env;
</p>
550 <p class=
"p6"><span class=
"Apple-tab-span"> </span>env =
<span class=
"s1">EnvGen
</span>.ar(
<span class=
"s1">Env
</span>.linen(
0.01, sustain,
0.01),
1, doneAction:
2);
</p>
551 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(out,
</p>
552 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">BufRd
</span>.ar(
1, bufnum,
<span class=
"Apple-converted-space"> </span></p>
553 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">Line
</span>.ar(from, to, sustain) *
<span class=
"s1">BufFrames
</span>.kr(bufnum)
</p>
554 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>) * env
</p>
555 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
556 <p class=
"p3"><br></p>
557 <p class=
"p3"><br></p>
558 <p class=
"p6">}).store;
</p>
560 <p class=
"p3"><br></p>
561 <p class=
"p11"><span class=
"s2">s.sendMsg(
</span>"/b_allocRead"<span class=
"s2">,
170,
</span>"sounds/a11wlk01.wav"<span class=
"s2">);
</span></p>
562 <p class=
"p3"><br></p>
563 <p class=
"p3"><br></p>
565 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\poch
</span>, {
<span class=
"s1">arg
</span> sustain=
1.0, from=
0.0, to=
1.0, n=
3;
</p>
566 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> step;
</p>
567 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>sustain = sustain.value;
</p>
568 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>step = (to - from) / n;
</p>
569 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
570 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\play_from_to
<span class=
"s2">,
</span></p>
571 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\from
</span>,
<span class=
"s1">Pseries
</span>(from, step, n),
</p>
572 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\to
</span>,
<span class=
"s1">Pseries
</span>(from, step, n) + step,
</p>
573 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
1.0,
</p>
574 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, sustain / n
</p>
575 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
578 <p class=
"p3"><br></p>
579 <p class=
"p9">// this plays it straight
</p>
581 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
582 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
583 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\poch
<span class=
"s2">,
</span></p>
584 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\recursionLevel
<span class=
"s2">,
3,
</span></p>
585 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\from
</span>,
0,
</p>
586 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\to
</span>,
1,
</p>
587 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
3,
</p>
588 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\bufnum
<span class=
"s2">,
170</span></p>
589 <p class=
"p6">).play
</p>
591 <p class=
"p3"><br></p>
592 <p class=
"p9">// now turn round every middle part of every middle part
</p>
594 <p class=
"p6"><span class=
"s1">Pdef
</span>(
<span class=
"s3">\poch
</span>, {
<span class=
"s1">arg
</span> sustain=
1.0, from=
0.0, to=
1.0, n=
3;
</p>
595 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> step, f, t, i;
</p>
596 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>sustain = sustain.value;
</p>
597 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>step = (to - from) / n;
</p>
598 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f =
<span class=
"s1">Array
</span>.series(n, from, step) +.t [
0.0, step];
</p>
599 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i = n div:
2;
</p>
600 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f[i] = f[i].reverse;
</p>
601 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>Pbind
<span class=
"s2">(
</span></p>
602 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\play_from_to
<span class=
"s2">,
</span></p>
603 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
<span class=
"s3">\from
</span>,
<span class=
"s3">\to
</span>],
<span class=
"s1">Pseq
</span>(f),
</p>
604 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\legato
</span>,
1.0,
</p>
605 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>, sustain / n
</p>
606 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
609 <p class=
"p3"><br></p>
610 <p class=
"p3"><br></p>
611 <p class=
"p9">// varying recursion
</p>
613 <p class=
"p7">Pbind
<span class=
"s2">(
</span></p>
614 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s2">,
</span>\phrase
<span class=
"s2">,
</span></p>
615 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>\instrument
<span class=
"s2">,
</span>\poch
<span class=
"s2">,
</span></p>
616 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\recursionLevel
</span>,
<span class=
"s1">Prand
</span>([
0,
1,
2,
3],
<span class=
"s1">inf
</span>),
</p>
617 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\from
</span>,
0,
</p>
618 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\to
</span>,
<span class=
"s1">Prand
</span>([-
1,
1],
<span class=
"s1">inf
</span>),
</p>
619 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\dur
</span>,
3,
</p>
620 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\n
</span>,
<span class=
"s1">Prand
</span>([
1,
2,
3],
<span class=
"s1">inf
</span>),
</p>
621 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\bufnum
</span>,
170,
</p>
622 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s3">\amp
</span>,
0.2</p>
623 <p class=
"p6">).play
</p>
625 <p class=
"p3"><br></p>
626 <p class=
"p3"><br></p>