Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / HelpSource / Classes / Pn.schelp
blobf72bcc862396c3e5c53bd8ba742bd5dc90a5561b
1 class:: Pn
2 summary:: repeatedly embed a pattern
3 related:: Classes/Pstutter
4 categories:: Streams-Patterns-Events>Patterns>Repetition
6 ClassMethods::
8 method::new
10 argument::pattern
11 the pattern to repeat
13 argument::repeats
14 Repeats the enclosed pattern strong::repeats:: times.
16 argument::key
17 If strong::key:: is non-nil, it sets the value of that key to true whenever it restarts the pattern. This can be used to advance Patterns enclosed by link::Classes/Pgate::.
19 Examples::
21 code::
23 var a, b;
24 a = Pn(Pseq(#[1, 2, 3], 1), 4); // repeat pattern four times
25 b = a.asStream;
26 16.do({ b.next.postln; });
29 // sound example
31 SynthDef(\help_sinegrain,
32         { arg out=0, freq=440, sustain=0.05;
33                 var env;
34                 env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
35                 Out.ar(out, SinOsc.ar(freq, 0, env))
36         }).add;
40 var a;
41 a = Pn(Pshuf([1, 2, 2, 3, 3, 3], 4)).asStream;
43         loop {
44                 Synth(\help_sinegrain, [\freq, a.next * 600 + 300]);
45                 0.2.wait;
46         }
47 }.fork;