Removing an old, cherished, yet pointless caveat "This documentation is
[supercollider.git] / Help / Streams-Patterns-Events / Streams-Patterns-Events6.html
blob70bb6ee54627448afdc11ae389cedf6a14896bed
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="824.44">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
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: 12.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0000bf}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; min-height: 17.0px}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0000ff}
22 span.s1 {color: #000000}
23 span.s2 {color: #0000bf}
24 span.s3 {color: #007300}
25 span.s4 {color: #bf0000}
26 span.Apple-tab-span {white-space:pre}
27 </style>
28 </head>
29 <body>
30 <p class="p1"><br></p>
31 <p class="p2"><b>Understanding Streams, Patterns and Events - Part 6</b></p>
32 <p class="p1"><br></p>
33 <p class="p2"><b>Parallel Patterns</b></p>
34 <p class="p3"><br></p>
35 <p class="p4"><b>Ppar</b></p>
36 <p class="p3"><br></p>
37 <p class="p5">The <b>Ppar</b> pattern allows you to merge multiple event streams to play in parallel.</p>
38 <p class="p3"><br></p>
39 <p class="p5">Ppar is a ListPattern and so like most ListPatterns it takes two arguments, a <b>list</b> of event patterns to play in parallel and a <b>repeats</b> count.</p>
40 <p class="p3"><br></p>
41 <p class="p5">Ppar's child patterns must be event patterns. Using value patterns in a Ppar is an error because value patterns contain no duration data.</p>
42 <p class="p3"><br></p>
43 <p class="p5">A Ppar is done when all of its subpatterns are done.</p>
44 <p class="p3"><br></p>
45 <p class="p6">(</p>
46 <p class="p7">Ppar<span class="s1">([</span></p>
47 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbind</span>(<span class="s3">\dur</span>, 0.2, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([62, 65, 69, 72], <span class="s2">inf</span>)),</p>
48 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbind</span>(<span class="s3">\dur</span>, 0.4, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([50, 45], <span class="s2">inf</span>))</p>
49 <p class="p6">]).play</p>
50 <p class="p6">)</p>
51 <p class="p8"><br></p>
52 <p class="p8"><br></p>
53 <p class="p6">(</p>
54 <p class="p9">// Ppars can be nested</p>
55 <p class="p7">Ppar<span class="s1">([</span></p>
56 <p class="p7"><span class="s1"><span class="Apple-tab-span"> </span></span>Pbind<span class="s1">(</span></p>
57 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\dur</span>, <span class="s2">Prand</span>([0.2, 0.4, 0.6], <span class="s2">inf</span>),<span class="Apple-converted-space"> </span></p>
58 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\midinote</span>, <span class="s2">Prand</span>([72, 74, 76, 77, 79, 81], <span class="s2">inf</span>),</p>
59 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\db</span>, -26,</p>
60 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\legato</span>, 1.1</p>
61 <p class="p6"><span class="Apple-tab-span"> </span>),</p>
62 <p class="p7"><span class="s1"><span class="Apple-tab-span"> </span></span>Pseq<span class="s1">([</span></p>
63 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Pbind</span>(<span class="s3">\dur</span>, 3.2, <span class="s3">\freq</span>, <span class="s2">Pseq</span>([<span class="s3">\rest</span>]) ),</p>
64 <p class="p7"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>Prand<span class="s1">([</span></p>
65 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Ppar</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="Apple-tab-span"> </span><span class="s2">Pbind</span>(<span class="s3">\dur</span>, 0.2, <span class="s3">\pan</span>,<span class="Apple-converted-space">  </span>0.5, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([60, 64, 67, 64])),</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="s2">Pbind</span>(<span class="s3">\dur</span>, 0.4, <span class="s3">\pan</span>, -0.5, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([48, 43]))</p>
68 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>]),</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="s2">Ppar</span>([</p>
70 <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="s2">Pbind</span>(<span class="s3">\dur</span>, 0.2, <span class="s3">\pan</span>,<span class="Apple-converted-space">  </span>0.5, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([62, 65, 69, 65])),</p>
71 <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="s2">Pbind</span>(<span class="s3">\dur</span>, 0.4, <span class="s3">\pan</span>, -0.5, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([50, 45]))</p>
72 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>]),</p>
73 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Ppar</span>([</p>
74 <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="s2">Pbind</span>(<span class="s3">\dur</span>, 0.2, <span class="s3">\pan</span>,<span class="Apple-converted-space">  </span>0.5, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([64, 67, 71, 67])),</p>
75 <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="s2">Pbind</span>(<span class="s3">\dur</span>, 0.4, <span class="s3">\pan</span>, -0.5, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([52, 47]))</p>
76 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>])</p>
77 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>], 12)</p>
78 <p class="p6"><span class="Apple-tab-span"> </span>], <span class="s2">inf</span>)</p>
79 <p class="p6">], <span class="s2">inf</span>).play;</p>
80 <p class="p6">)</p>
81 <p class="p10"><br></p>
82 <p class="p10"><br></p>
83 <p class="p4"><b>Ptpar</b></p>
84 <p class="p3"><br></p>
85 <p class="p5">The <b>Ppar</b> pattern starts all of its subpatterns at the same time.</p>
86 <p class="p3"><b></b><br></p>
87 <p class="p5"><b>Ptpar</b> pattern includes a start time parameter before each subpattern which allow the subpatterns to</p>
88 <p class="p5">be started at some time delay within the pattern. The start time is given in beats.</p>
89 <p class="p3"><br></p>
90 <p class="p6">(</p>
91 <p class="p6"><span class="s2">var</span> makePattern, durpat;</p>
92 <p class="p8"><br></p>
93 <p class="p6">durpat = <span class="s2">Pseq</span>([ <span class="s2">Pgeom</span>(0.05, 1.1, 24), <span class="s2">Pgeom</span>(0.5, 0.909, 24) ], 2);</p>
94 <p class="p8"><br></p>
95 <p class="p6">makePattern = { <span class="s2">arg</span> note, db, pan;</p>
96 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbind</span>( <span class="s3">\dur</span>, durpat, <span class="s3">\db</span>, db, <span class="s3">\pan</span>, pan, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([note, note-4], <span class="s2">inf</span>) );</p>
97 <p class="p6">};</p>
98 <p class="p8"><br></p>
99 <p class="p7">Ptpar<span class="s1">([</span></p>
100 <p class="p6"><span class="Apple-tab-span"> </span>0.0, makePattern.value(53, -20, -0.9),</p>
101 <p class="p6"><span class="Apple-tab-span"> </span>2.0, makePattern.value(60, -23, -0.3),</p>
102 <p class="p6"><span class="Apple-tab-span"> </span>4.0, makePattern.value(67, -26,<span class="Apple-converted-space">  </span>0.3),</p>
103 <p class="p6"><span class="Apple-tab-span"> </span>6.0, makePattern.value(74, -29,<span class="Apple-converted-space">  </span>0.9)</p>
104 <p class="p6">], <span class="s2">inf</span>).play;</p>
105 <p class="p8"><br></p>
106 <p class="p6">)</p>
107 <p class="p10"><br></p>
108 <p class="p10"><br></p>
109 <p class="p5">The time argmuents are sent the 'value' message when the Ptpar pattern is started, so you may use functions to specify the times.</p>
110 <p class="p3"><br></p>
111 <p class="p6">(</p>
112 <p class="p6"><span class="s2">var</span> makePattern, durpat;</p>
113 <p class="p8"><br></p>
114 <p class="p6">durpat = <span class="s2">Pseq</span>([ <span class="s2">Pgeom</span>(0.05, 1.1, 24), <span class="s2">Pgeom</span>(0.5, 0.909, 24) ], 2);</p>
115 <p class="p8"><br></p>
116 <p class="p6">makePattern = { <span class="s2">arg</span> note, db, pan;</p>
117 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbind</span>( <span class="s3">\dur</span>, durpat, <span class="s3">\db</span>, db, <span class="s3">\pan</span>, pan, <span class="s3">\midinote</span>, <span class="s2">Pseq</span>([note, note-4], <span class="s2">inf</span>) );</p>
118 <p class="p6">};</p>
119 <p class="p8"><br></p>
120 <p class="p7">Ptpar<span class="s1">([</span></p>
121 <p class="p6"><span class="Apple-tab-span"> </span>{ 0.0 }, makePattern.value(53, -20, -0.9),</p>
122 <p class="p6"><span class="Apple-tab-span"> </span>{ 8.0.rand }, makePattern.value(60, -23, -0.3),</p>
123 <p class="p6"><span class="Apple-tab-span"> </span>{ 8.0.rand }, makePattern.value(67, -26,<span class="Apple-converted-space">  </span>0.3),</p>
124 <p class="p6"><span class="Apple-tab-span"> </span>{ 8.0.rand }, makePattern.value(74, -29,<span class="Apple-converted-space">  </span>0.9)</p>
125 <p class="p6">], <span class="s2">inf</span>).play;</p>
126 <p class="p8"><br></p>
127 <p class="p6">)</p>
128 <p class="p3"><br></p>
129 <p class="p3"><br></p>
130 <p class="p2"><b>FilterPatterns and transformation</b></p>
131 <p class="p3"><br></p>
132 <p class="p5">FilterPatterns take an existing pattern and apply some modification to its properties.</p>
133 <p class="p11"><br></p>
134 <p class="p4"><b>Padd, Pmul, Pset, Pstretch</b></p>
135 <p class="p3"><br></p>
136 <p class="p5">There is a simpler way to write the modal transposition example given in part 5. In fact the earlier examples are setting the values of mtranspose and ctranspose which is not the best way to change those variables, because it wipes out any modifications to them by parent patterns. It is better to take the current value of those properties and add a value to them. The <b>Padd</b> filter takes the current value of a property and adds a value to it.</p>
137 <p class="p11"><br></p>
138 <p class="p6">(</p>
139 <p class="p9">// modal transposition</p>
140 <p class="p6"><span class="s2">var</span> pattern;</p>
141 <p class="p8"><br></p>
142 <p class="p9">// define the basic pattern</p>
143 <p class="p6">pattern = <span class="s2">Pbind</span>(</p>
144 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\dur</span>, 0.15,</p>
145 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\degree</span>, <span class="s2">Pseq</span>([ <span class="s2">Pshuf</span>(#[-7,-3,0,2,4,7], 4), <span class="s2">Pseq</span>([0,1,2,3,4,5,6,7]) ], 1)</p>
146 <p class="p6">);</p>
147 <p class="p8"><br></p>
148 <p class="p7">Pseq<span class="s1">([</span></p>
149 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span>pattern,<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// untransposed</p>
150 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Padd</span><span class="s1">(</span><span class="s3">\mtranspose</span><span class="s1">, 1, pattern),<span class="Apple-tab-span"> </span></span>// modal transpose up 1 degree</p>
151 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Padd</span><span class="s1">(</span><span class="s3">\mtranspose</span><span class="s1">, 2, pattern)<span class="Apple-tab-span"> </span></span>// modal transpose up 2 degrees</p>
152 <p class="p6">], <span class="s2">inf</span>).play</p>
153 <p class="p6">)</p>
154 <p class="p10"><br></p>
155 <p class="p5">Similarly, <b>Pmul</b> multiplies the current value of a property by a value.</p>
156 <p class="p5"><b>Pset</b> sets the property to a value.</p>
157 <p class="p5"><b>Pnot</b> does a logical negation of a property with a Boolean value.</p>
158 <p class="p11"><br></p>
159 <p class="p5">In order to process duration correctly <b>Pstretch</b> should be used.</p>
160 <p class="p3"><br></p>
161 <p class="p6">(</p>
162 <p class="p9">// beat stretching using Pstretch</p>
163 <p class="p6"><span class="s2">var</span> pattern;</p>
164 <p class="p8"><br></p>
165 <p class="p9">// define the basic pattern</p>
166 <p class="p6">pattern = <span class="s2">Pbind</span>(</p>
167 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\dur</span>, 0.15,</p>
168 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\degree</span>, <span class="s2">Pseq</span>([ <span class="s2">Pshuf</span>(#[-7,-3,0,2,4,7], 4), <span class="s2">Pseq</span>([0,1,2,3,4,5,6,7]) ], 1)</p>
169 <p class="p6">);</p>
170 <p class="p8"><br></p>
171 <p class="p7">Pseq<span class="s1">([</span></p>
172 <p class="p6"><span class="Apple-tab-span"> </span>pattern,<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">// normal</span></p>
173 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Pstretch</span><span class="s1">(0.5, pattern),<span class="Apple-tab-span"> </span></span>// stretch durations by a factor of 1/2</p>
174 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Pstretch</span><span class="s1">(2.0, pattern)<span class="Apple-tab-span"> </span></span>// stretch durations by a factor of 2</p>
175 <p class="p6">], <span class="s2">inf</span>).play</p>
176 <p class="p6">)</p>
177 <p class="p10"><br></p>
178 <p class="p3"><br></p>
179 <p class="p4"><b>Paddp, Pmulp, Psetp, Pstretchp</b></p>
180 <p class="p3"><br></p>
181 <p class="p5">In fact there is an even shorter version of the modal transposition example. <b>Paddp</b> reads one pattern to get values for adding to a property and plays the second pattern once through modified with each new value.</p>
182 <p class="p11"><br></p>
183 <p class="p6">(</p>
184 <p class="p9">// modal transposition</p>
185 <p class="p6"><span class="s2">var</span> pattern;</p>
186 <p class="p8"><br></p>
187 <p class="p9">// define the basic pattern</p>
188 <p class="p6">pattern = <span class="s2">Pbind</span>(</p>
189 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\dur</span>, 0.15,</p>
190 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\degree</span>, <span class="s2">Pseq</span>([ <span class="s2">Pshuf</span>(#[-7,-3,0,2,4,7], 4), <span class="s2">Pseq</span>([0,1,2,3,4,5,6,7]) ], 1)</p>
191 <p class="p6">);</p>
192 <p class="p8"><br></p>
193 <p class="p7">Paddp<span class="s1">(</span></p>
194 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s3">\mtranspose</span><span class="s1">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// property to be modified</p>
195 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Pseq</span><span class="s1">([0,1,2], </span><span class="s2">inf</span><span class="s1">), <span class="Apple-tab-span"> </span></span>// a value pattern as a source of values for adding to mtranspose</p>
196 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span>pattern<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>// the pattern to be modified</p>
197 <p class="p6">).play</p>
198 <p class="p6">)</p>
199 <p class="p10"><br></p>
200 <p class="p10"><br></p>
201 <p class="p5">Nested modifications:</p>
202 <p class="p3"><br></p>
203 <p class="p6">(</p>
204 <p class="p9">// modal transposition</p>
205 <p class="p6"><span class="s2">var</span> pat1, pat2;</p>
206 <p class="p8"><br></p>
207 <p class="p9">// define the basic pattern</p>
208 <p class="p6">pat1 = <span class="s2">Pbind</span>(</p>
209 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\dur</span>, 0.15,</p>
210 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\degree</span>, <span class="s2">Pseq</span>([ <span class="s2">Pshuf</span>(#[-7,-3,0,2,4,7], 4), <span class="s2">Pseq</span>([0,1,2,3,4,5,6,7]) ], 1)</p>
211 <p class="p6">);</p>
212 <p class="p8"><br></p>
213 <p class="p6">pat2 = <span class="s2">Paddp</span>(</p>
214 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s3">\mtranspose</span><span class="s1">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// property to be modified</p>
215 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Pseq</span><span class="s1">([0,1,2]), <span class="Apple-tab-span"> </span></span>// a value pattern as a source of values for adding to mtranspose</p>
216 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Ppar</span>([<span class="Apple-converted-space"> </span></p>
217 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>pat1,<span class="Apple-converted-space"> </span></p>
218 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Padd</span>(<span class="s3">\mtranspose</span>, -3, pat1), <span class="s4">// down a 4th</span></p>
219 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Padd</span>(<span class="s3">\mtranspose</span>, 2, pat1) <span class="Apple-tab-span"> </span><span class="s4">// up a 3rd</span></p>
220 <p class="p6"><span class="Apple-tab-span"> </span>])</p>
221 <p class="p6">);</p>
222 <p class="p8"><br></p>
223 <p class="p7">Pseq<span class="s1">([</span></p>
224 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span>pat1,<span class="Apple-tab-span"> </span></span>// unmodified pattern</p>
225 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span>pat2, <span class="Apple-tab-span"> </span></span>// parallel sequence</p>
226 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Pstretch</span><span class="s1">(1.5, pat2) <span class="Apple-tab-span"> </span></span>// parallel sequence stretched by 3/2</p>
227 <p class="p6">], <span class="s2">inf</span>).play</p>
228 <p class="p6">)</p>
229 <p class="p10"><br></p>
230 <p class="p3"><br></p>
231 <p class="p5">Another example using Paddp:</p>
232 <p class="p3"><br></p>
233 <p class="p6">(</p>
234 <p class="p6"><span class="s2">var</span> chord;</p>
235 <p class="p6">chord = <span class="s2">Prand</span>([[53, 58, 64],[53, 60, 64],[57,60,65]]);</p>
236 <p class="p6"><span class="s2">Paddp</span>(<span class="s3">\ctranspose</span>, <span class="s2">Prand</span>([-1,0,2,4,5], <span class="s2">inf</span>),<span class="Apple-converted-space"> </span></p>
237 <p class="p7"><span class="s1"><span class="Apple-tab-span"> </span></span>Ppar<span class="s1">([</span></p>
238 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Pbind</span><span class="s1">(<span class="Apple-tab-span"> </span></span>// melody part</p>
239 <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>, <span class="s2">Prand</span>([0.2, 0.4, 0.6], <span class="s2">inf</span>),<span class="Apple-converted-space"> </span></p>
240 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\midinote</span>, <span class="s2">Pxrand</span>([71, 72, 74, 76, 77, 79], 10),</p>
241 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\db</span>, -26,</p>
242 <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.1</p>
243 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>),</p>
244 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Pbind</span><span class="s1">(<span class="Apple-tab-span"> </span></span>// harmony part</p>
245 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\pan</span>, 0.4,<span class="Apple-converted-space"> </span></p>
246 <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>, <span class="s2">Pseq</span>([0.1, 0.5, 0.4, 0.6], 4),<span class="Apple-converted-space"> </span></p>
247 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\midinote</span>, <span class="s2">Pseq</span>([chord,<span class="s3">\rest</span>,chord,<span class="s3">\rest</span>], 4)</p>
248 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>),</p>
249 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Pbind</span><span class="s1">(<span class="Apple-tab-span"> </span></span>// bass part</p>
250 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\pan</span>, -0.4,<span class="Apple-converted-space"> </span></p>
251 <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>, 0.4,<span class="Apple-converted-space"> </span></p>
252 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\midinote</span>, <span class="s2">Pseq</span>([38, 45, 38, 36], 4)</p>
253 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
254 <p class="p6"><span class="Apple-tab-span"> </span>])</p>
255 <p class="p6">).play</p>
256 <p class="p6">)</p>
257 <p class="p8"><br></p>
258 <p class="p8"><br></p>
259 <p class="p6">(</p>
260 <p class="p9">// chromatic transposition</p>
261 <p class="p6"><span class="s2">var</span> pattern;</p>
262 <p class="p8"><br></p>
263 <p class="p9">// define the basic pattern</p>
264 <p class="p6">pattern = <span class="s2">Pbind</span>(</p>
265 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\dur</span>, 0.1,</p>
266 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\degree</span>, <span class="s2">Pseq</span>([0,1,2,3,4,5,6,7])</p>
267 <p class="p6">);</p>
268 <p class="p8"><br></p>
269 <p class="p7">Paddp<span class="s1">(</span></p>
270 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s3">\ctranspose</span><span class="s1">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// property to be modified</p>
271 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Pseries</span><span class="s1">(0,1,12), <span class="Apple-tab-span"> </span></span>// a value pattern as a source of values for multiplying with ctranspose</p>
272 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span>pattern<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// the pattern to be modified</p>
273 <p class="p6">).play</p>
274 <p class="p6">)</p>
275 <p class="p8"><br></p>
276 <p class="p8"><br></p>
277 <p class="p6">(</p>
278 <p class="p9">// beat time stretching</p>
279 <p class="p6"><span class="s2">var</span> pattern;</p>
280 <p class="p8"><br></p>
281 <p class="p9">// define the basic pattern</p>
282 <p class="p6">pattern = <span class="s2">Pbind</span>(</p>
283 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\dur</span>, 0.1,</p>
284 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\degree</span>, <span class="s2">Pseq</span>([0,1,2,3,4,5,6,7])</p>
285 <p class="p6">);</p>
286 <p class="p8"><br></p>
287 <p class="p7">Pstretchp<span class="s1">(</span></p>
288 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s2">Pseq</span><span class="s1">([1,2,3], </span><span class="s2">inf</span><span class="s1">), <span class="Apple-tab-span"> </span></span>// a value pattern as a source of values for multiplying with stretch</p>
289 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span>pattern<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>// the pattern to be modified</p>
290 <p class="p6">).play</p>
291 <p class="p6">)</p>
292 <p class="p10"><br></p>
293 <p class="p11"><br></p>
294 <p class="p4"><b>Pbindf</b></p>
295 <p class="p11"><br></p>
296 <p class="p5"><b>Pbindf</b> is like <b>Pbind</b> except that it merges all the bound symbols into events that it gets from a subpattern. It takes the same initial arguments in pairs as Pbind does, with an additional pattern to be modified as the last argument.</p>
297 <p class="p3"><br></p>
298 <p class="p6">(</p>
299 <p class="p6"><span class="s2">var</span> pattern;</p>
300 <p class="p6">pattern = <span class="s2">Pbind</span>( <span class="s3">\midinote</span>, <span class="s2">Pseq</span>(#[60, 62, 64, 65, 67, 69, 71, 72]) );</p>
301 <p class="p8"><br></p>
302 <p class="p7">Pseq<span class="s1">([</span></p>
303 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbindf</span>(pattern, <span class="s3">\legato</span>, 0.1, <span class="s3">\dur</span>, 0.2),</p>
304 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbindf</span>(pattern, <span class="s3">\legato</span>, 1.0, <span class="s3">\dur</span>, 0.125),</p>
305 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbindf</span>(pattern, <span class="s3">\legato</span>, 2.0, <span class="s3">\dur</span>, 0.3)</p>
306 <p class="p6">], <span class="s2">inf</span>).play</p>
307 <p class="p6">)</p>
308 <p class="p3"><br></p>
309 <p class="p3"><br></p>
310 <p class="p5">Patterns can be used as the arguments to Pbindf.</p>
311 <p class="p3"><br></p>
312 <p class="p6">(</p>
313 <p class="p6"><span class="s2">var</span> pattern;</p>
314 <p class="p6">pattern = <span class="s2">Pbind</span>( <span class="s3">\midinote</span>, <span class="s2">Pseq</span>(#[60, 62, 64, 65, 67, 69, 71, 72, 74, 76, 77, 79]) );</p>
315 <p class="p8"><br></p>
316 <p class="p7">Pseq<span class="s1">([</span></p>
317 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbindf</span>(pattern,<span class="s3">\legato</span>, 0.1, <span class="s3">\dur</span>, <span class="s2">Pgeom</span>(0.3, 0.85, <span class="s2">inf</span>)),</p>
318 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbindf</span>(pattern,<span class="s3">\legato</span>, 1.0, <span class="s3">\dur</span>, <span class="s2">Pseq</span>([0.3, 0.15], <span class="s2">inf</span>)),</p>
319 <p class="p6"><span class="Apple-tab-span"> </span><span class="s2">Pbindf</span>(pattern,<span class="s3">\legato</span>, 2.0, <span class="s3">\dur</span>, <span class="s2">Pseq</span>([0.2, 0.2, 0.4], <span class="s2">inf</span>))</p>
320 <p class="p6">], <span class="s2">inf</span>).play</p>
321 <p class="p6">)</p>
322 <p class="p10"><br></p>
323 <p class="p5">To go to the next file:</p>
324 <p class="p12"><a href="Streams-Patterns-Events7.html">Streams-Patterns-Events7</a></p>
325 <p class="p10"><br></p>
326 </body>
327 </html>