Debian Codegraph @

examples/stk/modalbar2.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 ) => int preset;
14 Math.random2f( 0, 128 ) => float stickHardness;
15 Math.random2f( 0, 128 ) => float strikePosition;
16 Math.random2f( 0, 128 ) => float vibratoGain;
17 Math.random2f( 0, 128 ) => float vibratoFreq;
18 Math.random2f( 0, 128 ) => float volume;
19 Math.random2f( 64, 128 ) => float directGain;
20 Math.random2f( 64, 128 ) => float masterGain;
21
22 bar.controlChange( 2, stickHardness );
23 bar.controlChange( 4, strikePosition );
24 bar.controlChange( 11, vibratoGain );
25 bar.controlChange( 7, vibratoFreq );
26 bar.controlChange( 1, directGain);
27 bar.controlChange( 128, volume );
28 bar.controlChange( 16, preset );
29
30 <<< "---", "" >>>;
31 <<< "preset:", preset >>>;
32 <<< "stick hardness:", stickHardness, "/ 128.0" >>>;
33 <<< "strike position:", strikePosition, "/ 128.0" >>>;
34 <<< "vibrato gain:", vibratoGain, "/ 128.0" >>>;
35 <<< "vibrato freq:", vibratoFreq, "/ 128.0" >>>;
36 <<< "volume:", volume, "/ 128.0" >>>;
37 <<< "direct gain:", directGain, "/ 128.0" >>>;
38 <<< "master gain:", masterGain, "/ 128.0" >>>;
39
40 // set freq
41 scale[Math.random2(0,scale.size()-1)] => int winner;
42 57 + Math.random2(0,2)*12 + winner => Std.mtof => bar.freq;
43 // go
44 .8 => bar.noteOn;
45
46 // advance time
47 .5::second => now;
48 }