2 summary:: synchronise and limit pattern duration
3 related:: Classes/Pfindur
4 categories:: Streams-Patterns-Events>Patterns>Repetition
8 Psync behaves somewhat like link::Classes/Pfindur:: -- it has a teletype::maxdur:: argument that limits the total duration of the event stream.
10 The difference is in what happens if the event pattern stops on its own before teletype::maxdur:: is reached. If the total duration of the event pattern is shorter than the given maximum duration:
13 ## Pfindur simply ends: no further time manipulation.
14 ## Psync inserts a rest to round the total duration up to the nearest multiple of the given teletype::quant::.
18 ## strong::Pbind's natural duration:: || code::Pfindur(16, Pbind(....)):: strong::behavior:: || code::Psync(Pbind(....), 4, 16):: strong::behavior::
19 ## 6 beats || Pfindur plays only 6 beats || Psync rounds up to 8 beats (adds a two-beat rest)
20 ## 18 beats || Pfindur cuts off after 16 beats || Psync cuts off after 16 beats
23 teletype::maxdur:: may be omitted. If the Pbind stops by itself, the rest will be inserted according to teletype::quant::, but the total duration will be unlimited.
30 a pattern that returns events.
33 rounding factor for total duration (effectively a "bar length")
39 difference threshhold that a pattern must exceed max to be ended.
45 SynthDef(\help_sinegrain,
46 { arg out=0, freq=440, sustain=0.05, pan;
48 env = EnvGen.kr(Env.perc(0.01, sustain, 0.3), doneAction:2);
49 Out.ar(out, Pan2.ar(SinOsc.ar(freq, 0, env), pan))
54 // a fixed duration pattern:
59 \instrument, \help_sinegrain
62 // this pattern has indetermined length:
65 \dur, Pseq([0.02, 0.002, 0.1, 0.1],2),
66 \degree, Pseq([9, 7, 5],inf),
67 \instrument, \help_sinegrain
70 \dur, Pseq([1, 0.35],2),
71 \degree, Pseq([0, [2b,5b]],inf),
72 \instrument, \help_sinegrain
75 \dur, Pseq([0.15, 0.25, 1.3],2),
76 \degree, Pseq([2b,4,5b],inf),
77 \instrument, \help_sinegrain
82 Pseq([f, f, a, a], inf).play; // play a sequence
85 // Psync allows to limit the duration of a stream relative to a beat grid
87 b = Psync(a, 1, 1); // create a sequence of exactly 1 beat elements
88 Pseq([f, f, b, b], inf).play;
91 b = Psync(a, 1, 2); // create a sequence of elements of either 1 or 2 beats length
92 Pseq([f, f, b, b], inf).play;
95 b = Psync(a, 2); // create a sequence of elements with a minimum of 2 beats,
96 // but with undetermined upper limit
98 Pseq([f, f, b, b], inf), // sequence
99 Pbind(\instrument, \help_sinegrain, \freq, 1000, \sustain, 0.01, \dur, 2) // metronome