2 summary:: event stream reference
3 categories:: Libraries>JITLib>Patterns
7 Keeps a reference to a task (time pattern) that can be replaced while playing. It plays on when the old stream ended and a new stream is set and schedules the changes to the beat.
12 create a new instance with a function (the source). the source should be a strong::routine function:: (see link::Classes/Tdef::) or a strong::pattern:: of time values.
15 a default source, if none is given. the default is a loop that does nothing with a 1.0 beat wait time.
18 set the default quantization value for the class. (default: 1.0). can be a pair [quant, offset]
23 set the source. If a quantization is given, schedule this change to the next beat the object is a strong::routine function::, which is evaluated in a protected way, so that failure will notify the proxy that it has stopped. The object can also be a strong::pattern:: of time values.
29 get or set the quantization value. can be a pair [quant, offset]
32 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
35 switch the pattern immediately. (stuck conditions can be subverted by this)
38 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.
41 set arguments in the environment. If there is none, it is created and the routine pattern is rebuilt.
44 returns a link::Classes/Proutine:: that plays the proxy endlessly, replacing strong::nil:: with a strong::default:: value (1 s. wait time). This allows to create streams that idle on until a new pattern is inserted.
46 subsection::a) using it as stream reference
49 set the routine function / pattern (internally done by *new(key, obj)
52 just like any stream, embeds itself in stream
54 subsection::b) using it as EventStreamPlayer
57 starts the TaskProxy and creates a player. if you want to play multiple instances, use strong::.playOnce(clock, protoEvent, quant)::
60 can be an array of [quant, phase]
66 the current player (if the TaskProxy is simply used in other streams this is nil)
68 method::pause, resume, reset
72 returns true if TaskProxy is running. if a TaskProxy 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) using TaskProxy as a player
79 // create an empty Tdef and play it.
84 x.source = { loop { "ggggggggggggggggg9999ggg999ggg999gg".scramble.postln; 0.5.wait; } };
87 x.source = { loop { "---------////----------------------".scramble.postln; 0.25.wait; } };
88 x.source = { loop { thisThread.seconds.postln; 1.wait; } };
89 x.source = { loop { thisThread.seconds.postln; 1.01.wait; } };
91 TempoClock.default.tempo = 2;
93 x.source = { "the end".postln };
94 x.source = { "one more".postln };
95 x.source = { 10.do { "ten more".scramble.postln; 0.25.wait; } };
96 x.source = { loop { "many more".scramble.postln; 0.25.wait; } };
98 TempoClock.default.tempo = 1;
112 SynthDef("pdef_grainlet",
113 { arg out=0, freq=440, sustain=0.05;
115 env = EnvGen.kr(Env.perc(0.01, sustain, 0.3), doneAction:2);
116 Out.ar(out, SinOsc.ar(freq, 0, env))
124 s.sendMsg("/s_new", "pdef_grainlet", -1,0,0, \freq, rrand(600, 640));
133 x = Pseries(300, 20, 100).loop.asStream;
135 s.sendMsg("/s_new", "pdef_grainlet", -1,0,0, \freq, x.next);
144 x = Plazy { Pseries(300 + 300.rand, 10 + 30.rand, 10 + 30.rand) }.loop.asStream;
146 s.sendMsg("/s_new", "pdef_grainlet", -1,0,0, \freq, x.next);
155 loop { s.sendMsg("/s_new", "pdef_grainlet", -1,0,0, \freq, 1500); 1.wait; }
160 // play ending stream once
164 dt = [0.1, 0.125, 0.05].choose;
165 x = Plazy { Pseries(1300 + 300.rand, 110 + 130.rand, 16) }.asStream;
167 s.sendMsg("/s_new", "pdef_grainlet", -1,0,0, \freq, item);
179 subsection::b) embedding TaskProxy into other Tasks / Routines
183 #a, c = { TaskProxy.new } ! 2;
184 a.source = { "one".postln; 1.wait; "two".postln };
185 c.source = { var z; z = Synth(\default); 0.5.wait; z.release };
187 "counting...".postln;
196 r.play; // play a stream
198 c.source = { var z; z = Synth(\default, [\freq, 300]); 1.5.wait; z.release }; // change the def
203 // of course TaskProxies can be used in other Tdefs:
207 "counting...".postln;
217 // if one wants to branch off a stream in a separate thread, asStream is used.