Debian Codegraph @

examples/stk/modalbar.ck

raw
1 // STK ModalBar
2
3 // patch
4 ModalBar bar => dac;
5
6 // scale
7 [0, 2, 4, 7, 8, 11] @=> int scale[];
8
9 // infinite time loop
10 while( true )
11 {
12 // ding!
13 Math.random2( 0, 8 ) => bar.preset;
14 Math.random2f( 0, 1 ) => bar.stickHardness;
15 Math.random2f( 0, 1 ) => bar.strikePosition;
16 Math.random2f( 0, 1 ) => bar.vibratoGain;
17 Math.random2f( 0, 60 ) => bar.vibratoFreq;
18 Math.random2f( 0, 1 ) => bar.volume;
19 Math.random2f( .5, 1 ) => bar.directGain;
20 Math.random2f( .5, 1 ) => bar.masterGain;
21
22 // print
23 <<< "---", "" >>>;
24 <<< "preset:", bar.preset() >>>;
25 <<< "stick hardness:", bar.stickHardness() >>>;
26 <<< "strike position:", bar.strikePosition() >>>;
27 <<< "vibrato gain:", bar.vibratoGain() >>>;
28 <<< "vibrato freq:", bar.vibratoFreq() >>>;
29 <<< "volume:", bar.volume() >>>;
30 <<< "direct gain:", bar.directGain() >>>;
31 <<< "master gain:", bar.masterGain() >>>;
32
33 // set freq
34 scale[Math.random2(0,scale.size()-1)] => int winner;
35 57 + Math.random2(0,2)*12 + winner => Std.mtof => bar.freq;
36 // go
37 .8 => bar.noteOn;
38
39 // advance time
40 .5::second => now;
41 }