Debian Codegraph @

examples/stk/mandolin.ck

raw
1 // STK Mandolin
2
3 // patch
4 Mandolin m => JCRev r => dac;
5 .75 => r.gain;
6 .025 => r.mix;
7
8 // our notes
9 [ 61, 63, 65, 66, 68, 66, 65, 63 ] @=> int notes[];
10
11 // infinite time-loop
12 while( true )
13 {
14 // set
15 Math.random2f( 0, 1 ) => m.bodySize;
16 Math.random2f( 0, 1 ) => m.pluckPos;
17 // Math.random2f( 0, 1 ) => m.stringDamping;
18 // Math.random2f( 0, 1 ) => m.stringDetune;
19
20 // print
21 <<< "---", "" >>>;
22 <<< "body size:", m.bodySize() >>>;
23 <<< "pluck position:", m.pluckPos() >>>;
24 <<< "string damping:", m.stringDamping() >>>;
25 <<< "string detune:", m.stringDetune() >>>;
26
27 // factor
28 Math.random2f( 1, 4 ) => float factor;
29
30 for( int i; i < notes.size(); i++ )
31 {
32 play( Math.random2(0,2)*12 + notes[i], Math.random2f( .6, .9 ) );
33 100::ms * factor => now;
34 }
35 }
36
37 // basic play function (add more arguments as needed)
38 fun void play( float note, float velocity )
39 {
40 // start the note
41 Std.mtof( note ) => m.freq;
42 velocity => m.pluck;
43 }