sclang: ServerShmInterface - try to avoid multiple destructor calls
[supercollider.git] / HelpSource / Classes / Dswitch.schelp
blob7d14e0228425ea85f3a397ae0c061e43e56f9d84
1 class:: Dswitch
2 summary:: Demand rate generator for embedding different inputs
3 related:: Classes/Demand, Classes/Dswitch1
4 categories:: UGens>Demand
6 description::
7 Demand rate generator for embedding different inputs.
8 In difference to Dswitch1, Dswitch embeds all items of
9 an input demand ugen first before looking up the next index.
11 classmethods::
12 method:: new(array, index)
13 argument:: array
14 array of values or other ugens
15 argument:: index
16 which of the inputs to return
17 discussion::
18 structurally related: link::Classes/Pswitch::
20 examples::
21 code::
23         {
24                 var d, trig;
25                 d = Dswitch([
26                         Dwhite(3, 4, 2),
27                         Dwhite(0, 1, 2),
28                         Dseq([1, 1, 1, 0], 2)
29                 ], Dseq([0, 1, 2, 1, 0], 2));
31                 trig = Impulse.kr(4);
33                 SinOsc.ar(
34                         Demand.kr(trig, 0, d).poll(trig)
35                         * 300 + 400
36                 )
37                 * 0.1 ! 2
38         }.play;
41 // compare with Dswitch1:
44         {
45                 var d, trig;
46                 d = Dswitch1([
47                         Dwhite(3, 4, 2),
48                         Dwhite(0, 1, 2),
49                         Dseq([1, 1, 1, 0], 2)
50                 ], Dseq([0, 1, 2, 1, 0], 2));
52                 trig = Impulse.kr(4);
54                 SinOsc.ar(
55                         Demand.kr(trig, 0, d).poll(trig)
56                         * 300 + 400
57                 )
58                 * 0.1 ! 2
59         }.play;