Debian Codegraph @

examples/stk/clarinet.ck

raw
1 // STK Clarinet
2 // (also see examples/event/polyfony2.ck)
3
4 // patch
5 Clarinet clair => JCRev r => dac;
6 .75 => r.gain;
7 .1 => r.mix;
8
9 // our notes
10 [ 61, 63, 65, 66, 68, 66, 65, 63, 61 ] @=> int notes[];
11
12 // infinite time-loop
13 while( true )
14 {
15 // clear
16 clair.clear( 1.0 );
17
18 // set
19 Math.random2f( 0, 1 ) => clair.reed;
20 Math.random2f( 0, 1 ) => clair.noiseGain;
21 Math.random2f( 0, 12 ) => clair.vibratoFreq;
22 Math.random2f( 0, 1 ) => clair.vibratoGain;
23 Math.random2f( 0, 1 ) => clair.pressure;
24
25 // print
26 <<< "---", "" >>>;
27 <<< "reed stiffness:", clair.reed() >>>;
28 <<< "noise gain:", clair.noiseGain() >>>;
29 <<< "vibrato freq:", clair.vibratoFreq() >>>;
30 <<< "vibrato gain:", clair.vibratoGain() >>>;
31 <<< "breath pressure:", clair.pressure() >>>;
32
33 for( int i; i < notes.size(); i++ )
34 {
35 play( 12 + notes[i], Math.random2f( .6, .9 ) );
36 300::ms => now;
37 }
38 }
39
40 // basic play function (add more arguments as needed)
41 fun void play( float note, float velocity )
42 {
43 // start the note
44 Std.mtof( note ) => clair.freq;
45 velocity => clair.noteOn;
46 }