Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / HelpSource / Classes / Pexprand.schelp
blob7cb3e8526d6becee4f627894e49726d7e4998fe4
1 class:: Pexprand
2 summary:: random values that follow a Exponential Distribution
3 related:: Classes/Pkey
4 categories:: Streams-Patterns-Events>Patterns>Random
6 ClassMethods::
8 method::new
9 note::
10 lo and hi should both be positive or negative (their range should not cross 0).
13 argument::lo
14 lower boundary of values.
16 argument::hi
17 upper boundary of values
19 argument::length
20 number of values produced.
22 Examples::
24 code::
26 var a;
27 a = Pexprand.new(0.0001, 1, inf);
28 c = a.asStream.nextN(500);
29 // plot the values
30 c.plot(bounds: Rect(10, 10, 520, 380), discrete: true, parent: w);
31 // a histogram of the values
32 c.histo(500).plot(bounds: Rect(10, 410, 520, 380), parent: w);
35 // sound example
37 SynthDef(\help_sinegrain,
38         { arg out=0, freq=440, sustain=0.05;
39                 var env;
40                 env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
41                 Out.ar(out, SinOsc.ar(freq, 0, env))
42         }).add;
47 var a;
48 a = Pexprand(0.0001, 1.0,inf).asStream;
50         loop {
51                 Synth(\help_sinegrain, [\freq, a.next * 600 + 300]);
52                 0.02.wait;
53         }
54 }.fork;