Debian Codegraph @

examples/stk/mode-o-test.ck

raw
1 //---------------|
2 // modal demo
3 // by: Ge Wang ([email protected])
4 // Perry R. Cook ([email protected])
5 //------------------|
6
7 // our patch
8 ModalBar modey => JCRev r => dac;
9
10 // set the gain
11 .95 => r.gain;
12 // set the reverb mix
13 .1 => r.mix;
14
15 // scale
16 [ 0, 2, 4, 7, 9, 11 ] @=> int scale[];
17
18 int which;
19 // our main loop
20 while( true )
21 {
22 // cycle through
23 ( which + 1 ) % 9 => which;
24 which => modey.preset;
25
26 // frequency...
27 scale[Math.random2(0,scale.size()-1)] => int freq;
28 Math.mtof( 33 + (Math.random2(0,3)*12) + freq ) => modey.freq;
29
30 // velocity
31 Math.random2f( 0.4, 0.8 ) => float v;
32
33 <<< "playing:", which, "freq:", Std.ftom(modey.freq()) $ int, "vel:", v >>>;
34
35 repeat( 4 )
36 {
37 // position
38 Math.random2f( 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 }
46 }