linux: shared memory interface - link with librt
[supercollider.git] / HelpSource / Classes / TWindex.schelp
blobe5c7fbb8e07b68a5fedb858a6996fcf3bb635cf6
1 class:: TWindex
2 summary:: Triggered windex.
3 categories:: UGens>Random, UGens>Triggers
6 Description::
8 When triggered, returns a random index value based on array as a list of
9 probabilities. By default the list of probabilities should sum to 1.0,
10 when the normalize flag is set to 1, the values get normalized
11 by the UGen (less efficient).
14 classmethods::
16 method::ar, kr
18 argument::in
20 The trigger. Trigger can be any signal. A trigger happens when
21 the signal changes from non-positive to positive.
24 argument::array
25 The list of probabilities.
27 argument::normalize
28 Controls whether to normalize the probability values.
30 Examples::
32 code::
34 //assuming normalized values
37 a = SynthDef("help-TWindex",{ arg w1=0.0, w2=0.5, w3=0.5;
39         var trig, index;
40         trig = Impulse.kr(6);
41         index = TWindex.kr(trig, [w1, w2, w3]);
43         Out.ar(0,
44                 SinOsc.ar(
45                         Select.kr(index,[400, 500, 600]),
46                         0, 0.2
47                 )
48         )
49 }).play;
53 a.setn(0, [0,0,1].normalizeSum);
54 a.setn(0, [1,1,1].normalizeSum);
55 a.setn(0, [1,0,1].normalizeSum);
58 //modulating probability values
61 a = SynthDef("help-TWindex",{ arg w1=0.0, w2=0.5;
63         var trig, index;
64         trig = Impulse.kr(6);
65         index = TWindex.kr(
66                                         trig,
67                                         [w1, w2, SinOsc.kr(0.3, 0, 0.5, 0.5)],//modulate probability
68                                         1 //do normalisation
69                 );
71         Out.ar(0,
72                 SinOsc.ar(
73                         Select.kr(index,[400, 500, 600]),
74                         0, 0.2
75                 )
76         )
77 }).play;
81 a.setn(0, [0,0]);
82 a.setn(0, [1,1]);
83 a.setn(0, [1,0]);
84 a.setn(0, [0,1]);