Debian Codegraph @

examples/stk/bowed2.ck

raw
1 // patch
2 Bowed bow => dac;
3
4 // scale
5 [0, 2, 4, 7, 8, 11] @=> int scale[];
6
7 // infinite time loop
8 while( true )
9 {
10 Math.random2f( 0, 128 ) => float pressure;
11 Math.random2f( 0, 128 ) => float position;
12 Math.random2f( 0, 128 ) => float vibratofreq;
13 Math.random2f( 0, 128 ) => float vibratogain;
14 Math.random2f( 0, 128 ) => float volume;
15
16 <<< "---", "" >>>;
17 <<< "bow pressure:", pressure >>>;
18 <<< "bow position:", position >>>;
19 <<< "vibrato freq:", vibratofreq >>>;
20 <<< "vibrato gain:", vibratogain >>>;
21 <<< "volume:", volume >>>;
22
23 // bow pressure
24 bow.controlChange( 2, pressure );
25 // bow position
26 bow.controlChange( 4, position );
27 // vibrato freq
28 bow.controlChange( 11, vibratofreq );
29 // vibrato gain
30 bow.controlChange( 1, vibratogain );
31 // volume
32 bow.controlChange( 128, volume );
33
34 // set freq
35 scale[Math.random2(0,scale.size()-1)] + 57 => Std.mtof => bow.freq;
36 // go
37 .8 => bow.noteOn;
38
39 // advance time
40 Math.random2f(.8, 2)::second => now;
41 }