*** empty log message ***
[chuck-blob.git] / v2 / examples / stk / modalbar2.ck
blob8f5c5ff24843a90212339df9fb331dfd50607833
1 // STK ModalBar
3 // patch
4 ModalBar bar => dac;
6 // scale
7 [0, 2, 4, 7, 8, 11] @=> int scale[];
9 // infinite time loop
10 while( true )
12     // ding!
13     Std.rand2( 0, 8 ) => int preset;
14     Std.rand2f( 0, 128 ) => float stickHardness;
15     Std.rand2f( 0, 128 ) => float strikePosition;
16     Std.rand2f( 0, 128 ) => float vibratoGain;
17     Std.rand2f( 0, 128 ) => float vibratoFreq;
18     Std.rand2f( 0, 128 ) => float volume;
19     Std.rand2f( 64, 128 ) => float directGain;
20     Std.rand2f( 64, 128 ) => float masterGain;
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 );
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" >>>;
40     // set freq
41         scale[Std.rand2(0,scale.cap()-1)] => int winner;
42     57 + Std.rand2(0,2)*12 + winner => Std.mtof => bar.freq;
43     // go
44     .8 => bar.noteOn;
46     // advance time
47     .5::second => now;