class library: SynthDef - lazy implementation of removeUGen
[supercollider.git] / HelpSource / Classes / TWChoose.schelp
blobca700d1550fedac1838edda9aa22e4fd001da4e1
1 class:: TWChoose
2 summary:: Randomly select one of several inputs
3 categories:: UGens>Triggers, UGens>Random
4 related:: Classes/TChoose
6 description::
7 An output is selected randomly on recieving a trigger from an array of inputs.
9 the code::weights:: of this choice are determined from the weights array.
11 If code::normalize:: is set to 1 the weights are continuously normalized (this is an extra overhead) when using fixed values the code::normalizeSum:: method can be used to normalize the values.
13 TWChoose is a composite of link::Classes/TWindex:: and link::Classes/Select::.
15 classmethods::
16 method:: ar, kr
18 argument:: trig
19 argument:: array
20 argument:: weights
21 argument:: normalize
23 examples::
24 code::
27         var a;
28         a = [
29                         SinOsc.ar,
30                         Saw.ar,
31                         Pulse.ar
32                 ];
33         TWChoose.ar(Dust.ar(MouseX.kr(1, 1000, 1)), a, [0.99, 0.05, 0.05].normalizeSum) * 0.2
35 }.play;
39 note:: all the ugens are continously running. This may not be the most efficient way if each input is  cpu-expensive.::