*** empty log message ***
[chuck-blob.git] / v2 / examples / stk / clarinet.ck
blob9e4a8ec2f69bd1ef92d1d697ad8f422f40ac1b09
1 // STK Clarinet
2 // (also see examples/event/polyfony2.ck)
4 // patch
5 Clarinet clair => JCRev r => dac;
6 .75 => r.gain;
7 .1 => r.mix;
9 // our notes
10 [ 61, 63, 65, 66, 68, 66, 65, 63, 61 ] @=> int notes[];
12 // infinite time-loop
13 while( true )
15     // clear
16     clair.clear( 1.0 );
18     // set
19     Std.rand2f( 0, 1 ) => clair.reed;
20     Std.rand2f( 0, 1 ) => clair.noiseGain;
21     Std.rand2f( 0, 12 ) => clair.vibratoFreq;
22     Std.rand2f( 0, 1 ) => clair.vibratoGain;
23     Std.rand2f( 0, 1 ) => clair.pressure;
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() >>>;
33     for( int i; i < notes.cap(); i++ )
34     {
35         play( 12 + notes[i], Std.rand2f( .6, .9 ) );
36         300::ms => now;
37     }
40 // basic play function (add more arguments as needed)
41 fun void play( float note, float velocity )
43     // start the note
44     Std.mtof( note ) => clair.freq;
45     velocity => clair.noteOn;