1 class:: EventPatternProxy
2 summary:: event stream reference
3 categories:: Libraries>JITLib>Patterns
7 Keeps a reference to a stream that can be replaced while playing. Multiple streams are thus handled without creating dependancies.
12 create a new instance with a pattern (the source). The pattern should be an emphasis::event pattern:: (see link::Classes/Pdef::)
15 a default source, if none is given. the default is a Pbind with resting notes of 1.0 beat duration.
18 set the default quantization value for the class.
23 set the source (a pattern). If a quantization is given, schedule this change to the next beat ( strong::pattern_::(..) is equivalent)
29 get or set the quantization value. can be an array [quant, phase, offset, outset]
32 when the synthdefs that are used contain an code::\amp:: control, the patterns are replaced by crossfading the previous with the new over this time (in beats)
35 provide a default event for the Pdef. It is used to filter the incoming stream before it is passed to the source pattern. This is similar to link::Classes/NodeProxy#-nodeMap::. When set for the first time, the pattern is rebuilt.
38 set arguments in the default event. If there is none, it is created and the pattern is rebuilt.
40 subsection::a) using as stream reference
43 just like any pattern, embeds itself in stream
45 subsection::b) using as EventStreamPlayer
48 starts the EventPatternProxy and creates a player. if you want to play multiple instances, use link::#-fork::.
51 can be an array of [quant, phase, offset, outset]
57 the current player (if the Pdef is simply used in other streams this is code::nil::)
59 method::pause, resume, reset
63 returns true if Pdef is running. if a Pdef is playing and its stream ends, it will schedule a stream for playing as soon as a new one is assigned to it.
68 subsection::a) embedding EventPatternProxy in streams
72 SynthDef("Pdefhelp", { arg out, freq, sustain=1, amp=1, pan;
74 env = EnvGen.kr(Env.perc(0.03, sustain), 1, doneAction:2);
75 5.do { var d; d = exprand(0.01, 1); u = SinOsc.ar(d * 300, u, rrand(0.1,1.2) * d, 1) };
76 Out.ar(out, Pan2.ar(SinOsc.ar(u + 1 * freq, 0, amp * env), pan));
82 #a, b, c, m = { EventPatternProxy.new } ! 4;
85 m.source = Pbind(\instrument, \Pdefhelp, \dur, 1, \degree, 16, \legato, 0.1);
87 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[0, 5, 4, 3]));
88 b.source = Pbind(\instrument, \Pdefhelp, \dur, 0.125, \degree, Pseq(#[7, 8, 7, 8]));
89 c.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[0, 1, 2], 2));
91 x = Pseq([a, b, c], inf).play;
94 c.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[4, 3, 1, 2]*3));
97 // infinite loops are scheduled (to ths clock's next beat by default) and released:
99 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.753, \degree, Pseq(#[0, 5, 4, 3, 2], inf));
100 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.125, \degree, Pseq(#[0, 5, 4, 3] + 1, 1));
101 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[0, 5, 4, 3] - 1, 1));
103 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.125, \degree, Pseq(#[0, 5] - 1, 1));
104 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.753, \degree, Pshuf(#[0, 5, 4, 3, 2], inf));
109 // EventPatternProxy can be used in multiple patterns
114 \gtranspose, Pstutter(8, Pseq(#[0, 2, 0, 3],inf))
117 \gtranspose, Pstutter(8, Pseq(#[7, 4, 0, 3],inf)),
121 \degree, Pseq(#[0, 5, 4, 3, 2, 3, 2], 1)
126 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.1, \degree, Pseq(#[0, 1, 0, 1, 2], inf));
128 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.2, \degree, Pseq([0, 4], inf));
130 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.2, \degree, Pseq([0, 4, Prand([6, 8b],2)], inf));
132 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.1, \degree, Pseq(#[0, 1b, 1, 2b, 2, 3, 4b, 4, 5], inf));
134 a.set(\detune, -50); // set environment
140 subsection::b) playing EventPatternProxy
147 { arg out=0, freq=440, sustain=0.05, amp=0.1, pan;
149 env = EnvGen.kr(Env.perc(0.01, sustain), doneAction:2) * amp;
150 Out.ar(out, Pan2.ar(SinOsc.ar(freq, 0, env), pan))
155 #x, y = {EventPatternProxy.new} ! 2;
157 x.play; // play them. A silent resting pattern is used.
161 // assign various patterns to it:
163 x.source = Pbind(\dur, 0.25, \instrument, \gpdef);
164 x.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6], inf), \instrument, \gpdef);
165 x.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6]+1, inf), \instrument, \gpdef);
166 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6]-1, inf), \instrument, \gpdef);
167 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b]-2, inf), \instrument, \gpdef);
172 y.source = Pbind(\dur, 0.125, \degree, Pseq([3, 4, 5b, 6]+4.rand, inf), \instrument, \gpdef);
173 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6]-2, inf), \instrument, \gpdef);
178 \degree, Pseq([3, 4, Prand([8, 2, 3, 9, 10],1) - 5, 6]+1, inf),
186 \degree, Pseq([3, 4, Prand([8, 2, 3, 9, 10],1), 6], inf),
195 TempoClock.default.tempo = 1.3;
196 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5, 6]+1, inf), \instrument, \gpdef);
198 // drop in ending patterns
203 x.source = Pbind(\dur, 0.25, \degree, Pseq([3, [7,4], 5, 6]-2), \instrument, \gpdef);
204 x.source = Pbind(\dur, 0.125, \degree, Pseq([3, [7,4], 5, 4]-3), \instrument, \gpdef);
205 x.source = Pbind(\dur, 0.35, \degree, Pseq([3, [7,4], 5, 4, 3]-3), \instrument, \gpdef);
206 x.source = Pbind(\dur, 0.25, \degree, Pshuf([3, [7,4], 5, 6]-2), \instrument, \gpdef);
210 TempoClock.default.tempo = 1.0;