*** empty log message ***
[chuck-blob.git] / v2 / examples / stk / mode-o-test.ck
blob70a6978ef07f941f7363a53d8b9d817fdc07931d
1 //---------------|
2 // modal demo
3 // by: Ge Wang (gewang@cs.princeton.edu)
4 //     Perry R. Cook (prc@cs.princeton.edu)
5 //------------------|
7 // our patch
8 ModalBar modey => JCRev r => dac;
10 // set the gain
11 .95 => r.gain;
12 // set the reverb mix
13 .1 => r.mix;
15 // scale
16 [ 0, 2, 4, 7, 9, 11 ] @=> int scale[];
18 int which;
19 // our main loop
20 while( true )
22     // cycle through
23     ( which + 1 ) % 9 => which;
24     which => modey.preset;
26     // frequency...
27     scale[Std.rand2(0,scale.cap()-1)] => int freq;
28     Math.mtof( 33 + (Std.rand2(0,3)*12) + freq ) => modey.freq;
30     // velocity
31     Std.rand2f( 0.4, 0.8 ) => float v;
33     <<< "playing:", which, "freq:", Std.ftom(modey.freq()) $ int, "vel:", v >>>;
35     repeat( 4 )
36     {
37         // position
38         Std.rand2f( 0.2, 0.8 ) => float p => modey.strikePosition;
39         // strike it!
40         v => modey.strike;
41         // print
42         <<< "    strike position:", p >>>;
43         // advance time
44         250::ms => now;
45     }