Debian Codegraph @

examples/stk/brass.ck

raw
1 // patch
2 Brass brass => JCRev r => dac;
3 .75 => r.gain;
4 .05 => r.mix;
5
6 // our notes
7 [ 61, 63, 65, 66, 68 ] @=> int notes[];
8
9 // infinite time-loop
10 while( true )
11 {
12 // set
13 Math.random2f( 0, 1 ) => brass.lip;
14 Math.random2f( 0, 1 ) => brass.slide;
15 Math.random2f( 0, 12 ) => brass.vibratoFreq;
16 Math.random2f( 0, 1 ) => brass.vibratoGain;
17 Math.random2f( 0, 1 ) => brass.volume;
18
19 // print
20 <<< "---", "" >>>;
21 <<< "lip tension:", brass.lip() >>>;
22 <<< "slide length:", brass.slide() >>>;
23 <<< "vibrato freq:", brass.vibratoFreq() >>>;
24 <<< "vibrato gain:", brass.vibratoGain() >>>;
25 <<< "volume:", brass.volume() >>>;
26
27 for( int i; i < notes.size(); i++ )
28 {
29 play( 12 + notes[i], Math.random2f( .6, .9 ) );
30 300::ms => now;
31 }
32 }
33
34 // basic play function (add more arguments as needed)
35 fun void play( float note, float velocity )
36 {
37 // start the note
38 Std.mtof( note ) => brass.freq;
39 velocity => brass.noteOn;
40 }