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)
26 set the source to nil and stop playing
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 play on a certain clock.
56 can be an array of [quant, phase, offset, outset]
59 a link::Classes/Boolean::
65 the current player (if the Pdef is simply used in other streams this is code::nil::)
67 method::pause, resume, reset
71 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.
76 subsection::a) embedding EventPatternProxy in streams
80 SynthDef("Pdefhelp", { arg out, freq, sustain=1, amp=1, pan;
82 env = EnvGen.kr(Env.perc(0.03, sustain), 1, doneAction:2);
83 5.do { var d; d = exprand(0.01, 1); u = SinOsc.ar(d * 300, u, rrand(0.1,1.2) * d, 1) };
84 Out.ar(out, Pan2.ar(SinOsc.ar(u + 1 * freq, 0, amp * env), pan));
90 #a, b, c, m = { EventPatternProxy.new } ! 4;
93 m.source = Pbind(\instrument, \Pdefhelp, \dur, 1, \degree, 16, \legato, 0.1);
95 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[0, 5, 4, 3]));
96 b.source = Pbind(\instrument, \Pdefhelp, \dur, 0.125, \degree, Pseq(#[7, 8, 7, 8]));
97 c.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[0, 1, 2], 2));
99 x = Pseq([a, b, c], inf).play;
102 c.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[4, 3, 1, 2]*3));
105 // infinite loops are scheduled (to ths clock's next beat by default) and released:
107 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.753, \degree, Pseq(#[0, 5, 4, 3, 2], inf));
108 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.125, \degree, Pseq(#[0, 5, 4, 3] + 1, 1));
109 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.25, \degree, Pseq(#[0, 5, 4, 3] - 1, 1));
111 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.125, \degree, Pseq(#[0, 5] - 1, 1));
112 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.753, \degree, Pshuf(#[0, 5, 4, 3, 2], inf));
117 // EventPatternProxy can be used in multiple patterns
122 \gtranspose, Pstutter(8, Pseq(#[0, 2, 0, 3],inf))
125 \gtranspose, Pstutter(8, Pseq(#[7, 4, 0, 3],inf)),
129 \degree, Pseq(#[0, 5, 4, 3, 2, 3, 2], 1)
134 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.1, \degree, Pseq(#[0, 1, 0, 1, 2], inf));
136 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.2, \degree, Pseq([0, 4], inf));
138 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.2, \degree, Pseq([0, 4, Prand([6, 8b],2)], inf));
140 a.source = Pbind(\instrument, \Pdefhelp, \dur, 0.1, \degree, Pseq(#[0, 1b, 1, 2b, 2, 3, 4b, 4, 5], inf));
142 a.set(\detune, -50); // set environment
148 subsection::b) playing EventPatternProxy
155 { arg out=0, freq=440, sustain=0.05, amp=0.1, pan;
157 env = EnvGen.kr(Env.perc(0.01, sustain), doneAction:2) * amp;
158 Out.ar(out, Pan2.ar(SinOsc.ar(freq, 0, env), pan))
163 #x, y = {EventPatternProxy.new} ! 2;
165 x.play; // play them. A silent resting pattern is used.
169 // assign various patterns to it:
171 x.source = Pbind(\dur, 0.25, \instrument, \gpdef);
172 x.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6], inf), \instrument, \gpdef);
173 x.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6]+1, inf), \instrument, \gpdef);
174 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6]-1, inf), \instrument, \gpdef);
175 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b]-2, inf), \instrument, \gpdef);
180 y.source = Pbind(\dur, 0.125, \degree, Pseq([3, 4, 5b, 6]+4.rand, inf), \instrument, \gpdef);
181 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5b, 6]-2, inf), \instrument, \gpdef);
186 \degree, Pseq([3, 4, Prand([8, 2, 3, 9, 10],1) - 5, 6]+1, inf),
194 \degree, Pseq([3, 4, Prand([8, 2, 3, 9, 10],1), 6], inf),
203 TempoClock.default.tempo = 1.3;
204 y.source = Pbind(\dur, 0.25, \degree, Pseq([3, 4, 5, 6]+1, inf), \instrument, \gpdef);
206 // drop in ending patterns
211 x.source = Pbind(\dur, 0.25, \degree, Pseq([3, [7,4], 5, 6]-2), \instrument, \gpdef);
212 x.source = Pbind(\dur, 0.125, \degree, Pseq([3, [7,4], 5, 4]-3), \instrument, \gpdef);
213 x.source = Pbind(\dur, 0.35, \degree, Pseq([3, [7,4], 5, 4, 3]-3), \instrument, \gpdef);
214 x.source = Pbind(\dur, 0.25, \degree, Pshuf([3, [7,4], 5, 6]-2), \instrument, \gpdef);
218 TempoClock.default.tempo = 1.0;