2 summary:: stream reference
3 categories:: Libraries>JITLib>Patterns
4 related:: Classes/Pdefn
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 a emphasis::value pattern:: (see link::Classes/Pdefn::).
14 for event pattern proxy, see: link::Classes/EventPatternProxy::. instead of a pattern, a strong::function:: can be passed in, creating a routine.
17 a default source, if none is given. the default is 1.0 (it is not 0.0 in order to make it safe for durations)
20 set the default quantization value for the class. (default: nil)
25 set the source. If a quantization is given, schedule this change to the next beat
31 set or get the quantization value
34 provide a condition under which the pattern is switched when a new one is inserted. the stream value and a count is passed into the function. the methods strong::count_(n):: simply counts up to n and switches the pattern then
37 just like any pattern, embeds itself in stream
39 subsection::extra methods
41 PatternProxy implements some methods for the benefits of its subclasses link::Classes/Pdefn:: / link::Classes/Pdef:: / link::Classes/Tdef:: which are not useful for link::Classes/PatternProxy:: and link::Classes/TaskProxy::.
44 provide a default environment for the proxy. If given, it is used as an environment for the routine function. When set for the first time, the routine pattern is rebuilt.
47 set arguments in the environment. If there is none, it is created and the pattern is rebuilt.
50 returns a Proutine that plays the proxy endlessly, replacing strong::nil:: with a strong::default:: value (1). This allows to create streams that idle on until a new pattern is inserted.
55 a = PatternProxy(Pseq([1, 2, 3], inf));
57 x = Pseq([0, 0, a], inf).asStream;
59 t = Task({ loop({ x.next.postln; 0.3.wait }) }).play;
62 a.source = Pseq([55, 66, 77], inf);
63 a.source = Pseq([55, 66, 77], 1);
69 // PatternProxy, like Pdefn can be accessed in multiple 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));
84 x.source = Pseq([0, 3, 2], inf);
86 Pset(\instrument, \Pdefhelp,
89 Pbind(\degree, x, \dur, 1/3)
94 x.source = Prand([0, 3, [1s, 4]], inf);
96 x.source = Pn(Pshuf([0, 3, 2, 7, 6], 2), inf);
100 // if quant is set, the update is done at the next beat or whatever is specified:
103 x.source = Pn(Pseries(0, 1, 8), inf);
105 x.quant = nil; // reactivate immediacy
111 #[2, 3, 4].choose.yield;
112 #[5, 0, 11].choose.yield;
113 #[6, 3, 4].choose.do { |j| (i % j).yield };