1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.42">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0000bf; min-height: 12.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 span
.s1
{font: 18.0px Helvetica
}
17 span
.s2
{color: #0000bf}
18 span
.s3
{color: #606060}
19 span
.s4
{color: #bf0000}
20 span
.s5
{color: #000000}
21 span
.Apple-tab-span
{white-space:pre
}
25 <p class=
"p1"><span class=
"s1"><b>TWindex
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>triggered windex
</b></p>
26 <p class=
"p2"><b></b><br></p>
27 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>*kr(trig,array,normalize)
</b></p>
28 <p class=
"p2"><b><span class=
"Apple-tab-span"> </span></b></p>
29 <p class=
"p1">When triggered, returns a random index value based on array as a list of probabilities.
</p>
30 <p class=
"p1">by default the list of probabilities should sum to
1.0, when the normalize flag is set to
1,
</p>
31 <p class=
"p1">the values get normalized by the ugen (less efficient)
</p>
32 <p class=
"p2"><b></b><br></p>
33 <p class=
"p3"><br></p>
34 <p class=
"p4">//assuming normalized values
</p>
36 <p class=
"p6"><br></p>
37 <p class=
"p5">a =
<span class=
"s2">SynthDef
</span>(
<span class=
"s3">"help-TWindex"</span>,{
<span class=
"s2">arg
</span> w1=
0.0, w2=
0.5, w3=
0.5;
</p>
38 <p class=
"p6"><br></p>
39 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> trig, index;
</p>
40 <p class=
"p5"><span class=
"Apple-tab-span"> </span>trig =
<span class=
"s2">Impulse
</span>.kr(
6);
</p>
41 <p class=
"p5"><span class=
"Apple-tab-span"> </span>index =
<span class=
"s2">TWindex
</span>.kr(trig, [w1, w2, w3]);
</p>
42 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
43 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">Out
</span>.ar(
0,
</p>
44 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">SinOsc
</span>.ar(
</p>
45 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Select
</span>.kr(index,[
400,
500,
600]),
</p>
46 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
0.2</p>
47 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
48 <p class=
"p5"><span class=
"Apple-tab-span"> </span>)
</p>
49 <p class=
"p5">}).play;
</p>
50 <p class=
"p6"><br></p>
52 <p class=
"p6"><br></p>
53 <p class=
"p5">a.setn(
0, [
0,
0,
1].normalizeSum);
</p>
54 <p class=
"p5">a.setn(
0, [
1,
1,
1].normalizeSum);
</p>
55 <p class=
"p5">a.setn(
0, [
1,
0,
1].normalizeSum);
</p>
56 <p class=
"p6"><br></p>
57 <p class=
"p6"><br></p>
58 <p class=
"p4">//modulating probability values
</p>
60 <p class=
"p6"><br></p>
61 <p class=
"p5">a =
<span class=
"s2">SynthDef
</span>(
<span class=
"s3">"help-TWindex"</span>,{
<span class=
"s2">arg
</span> w1=
0.0, w2=
0.5;
</p>
62 <p class=
"p6"><br></p>
63 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> trig, index;
</p>
64 <p class=
"p5"><span class=
"Apple-tab-span"> </span>trig =
<span class=
"s2">Impulse
</span>.kr(
6);
</p>
65 <p class=
"p5"><span class=
"Apple-tab-span"> </span>index =
<span class=
"s2">TWindex
</span>.kr(
</p>
66 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>trig,
<span class=
"Apple-converted-space"> </span></p>
67 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[w1, w2,
<span class=
"s2">SinOsc
</span>.kr(
0.3,
0,
0.5,
0.5)],
<span class=
"s4">//modulate probability
</span></p>
68 <p class=
"p4"><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>1 </span>//do normalisation
</p>
69 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
<span class=
"Apple-converted-space"> </span></p>
70 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
71 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">Out
</span>.ar(
0,
</p>
72 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">SinOsc
</span>.ar(
</p>
73 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Select
</span>.kr(index,[
400,
500,
600]),
</p>
74 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
0.2</p>
75 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
76 <p class=
"p5"><span class=
"Apple-tab-span"> </span>)
</p>
77 <p class=
"p5">}).play;
</p>
78 <p class=
"p6"><br></p>
80 <p class=
"p6"><br></p>
81 <p class=
"p5">a.setn(
0, [
0,
0]);
</p>
82 <p class=
"p5">a.setn(
0, [
1,
1]);
</p>
83 <p class=
"p5">a.setn(
0, [
1,
0]);
</p>
84 <p class=
"p5">a.setn(
0, [
0,
1]);
</p>
85 <p class=
"p6"><br></p>
86 <p class=
"p6"><br></p>