linux: shared memory interface - link with librt
[supercollider.git] / HelpSource / Classes / Psync.schelp
blobb0f64a12c50f7b846a6f5d5b61d187917180a632
1 class:: Psync
2 summary:: synchronise and limit pattern duration
3 related:: Classes/Pfindur
4 categories:: Streams-Patterns-Events>Patterns>Repetition
6 ClassMethods::
8 method::new
10 argument::pattern
11 a pattern that returns events.
13 argument::quant
15 argument::maxdur
17 argument::tolerance
18 difference threshhold that a pattern must exceed max to be ended.
20 Examples::
22 code::
24 SynthDef(\help_sinegrain,
25         { arg out=0, freq=440, sustain=0.05, pan;
26                 var env;
27                 env = EnvGen.kr(Env.perc(0.01, sustain, 0.3), doneAction:2);
28                 Out.ar(out, Pan2.ar(SinOsc.ar(freq, 0, env), pan))
29         }).add;
33 // a fixed duration pattern:
35 f = Pbind(
36         \dur, 0.5,
37         \degree, Pn(4,1),
38         \instrument, \help_sinegrain
41 // this pattern has indetermined length:
42 a = Prand([
43         Pbind(
44                 \dur, Pseq([0.02, 0.002, 0.1, 0.1],2),
45                 \degree, Pseq([9, 7, 5],inf),
46                 \instrument, \help_sinegrain
47         ),
48         Pbind(
49                 \dur, Pseq([1, 0.35],2),
50                 \degree, Pseq([0, [2b,5b]],inf),
51                 \instrument, \help_sinegrain
52         ),
53         Pbind(
54                 \dur, Pseq([0.15, 0.25, 1.3],2),
55                 \degree, Pseq([2b,4,5b],inf),
56                 \instrument, \help_sinegrain
57         )
58 ]);
61 Pseq([f, f, a, a], inf).play; // play a sequence
64 // Psync allows to limit the duration of a stream relative to a beat grid
66 b = Psync(a, 1, 1); // create a sequence of exactly 1 beat elements
67 Pseq([f, f, b, b], inf).play;
70 b = Psync(a, 1, 2); // create a sequence of elements of either 1 or 2 beats length
71 Pseq([f, f, b, b], inf).play;
74 b = Psync(a, 2);        // create a sequence of elements with a minimum of 2 beats,
75                         // but with undetermined upper limit
76 Ppar([
77         Pseq([f, f, b, b], inf), // sequence
78         Pbind(\instrument, \help_sinegrain, \freq, 1000, \sustain, 0.01, \dur, 2) // metronome
79 ]).play;