scide: implement selectionLength for openDocument
[supercollider.git] / HelpSource / Classes / Prorate.schelp
blob3f0658da126bf5d11a929a9f24f3fbc3588060fa
1 class:: Prorate
2 summary:: divide stream proportionally
3 related:: Classes/Pattern
4 categories:: Streams-Patterns-Events>Patterns>Math
6 ClassMethods::
8 method::new
10 argument::proportion
11 a pattern that returns either numbers (divides the pattern into pairs) or arrays of size n which are used to split up the input into n parts.
13 argument::pattern
14 a numerical pattern.
16 Examples::
18 code::
19 // divide 1 into various proportions
21 a = Prorate(Pseq([0.35, 0.5, 0.8]), 1);
22 x = a.asStream;
23 x.nextN(8)
26 // divide a pattern into various proportions
28 a = Prorate(Pseq([0.35, 0.5, 0.8]), Prand([20, 1], inf));
29 x = a.asStream;
30 x.nextN(8)
34 // divide 1 into several parts
36 a = Prorate(Pseq([[1, 2], [5, 7], [4, 8, 9]]).collect(_.normalizeSum), 1);
37 x = a.asStream;
38 x.nextN(8)
42 // sound example
45 SynthDef(\help_sinegrain,
46         { arg out=0, freq=440, sustain=0.05;
47                 var env;
48                 env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
49                 Out.ar(out, SinOsc.ar(freq, 0, env))
50         }).add;
54 var a, x;
55 a = Prorate(
56         Prand([2/3, 1/3, [0.3, 0.3, 0.4], [0.6, 0.4]], inf),
57         Pseq([1, 2, 1, 3, 12], inf)
60 3.do {
61         {
62         var x = a.asStream;
63         var freq = rrand(72, 84).midicps;
64                 loop {
65                         Synth(\help_sinegrain, [\freq, freq]);
66                         (0.25 * x.next).wait;
67                 }
68         }.fork;