Debian Codegraph @

examples/stk/brass2.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 Math.random2f( 64, 128 ) => float tension;
13 Math.random2f( 0, 128 ) => float length;
14 Math.random2f( 0, 128 ) => float vibratofreq;
15 Math.random2f( 0, 128 ) => float vibratogain;
16 Math.random2f( 64, 128 ) => float volume;
17
18 <<< "---", "" >>>;
19 <<< "lip tension:", tension >>>;
20 <<< "slide length:", length >>>;
21 <<< "vibrato freq:", vibratofreq >>>;
22 <<< "vibrato gain:", vibratogain >>>;
23 <<< "volume:", volume >>>;
24
25 // lip tension
26 brass.controlChange( 2, tension );
27 // slide length
28 brass.controlChange( 4, length );
29 // vibrato freq
30 brass.controlChange( 11, vibratofreq );
31 // vibrato gain
32 brass.controlChange( 1, vibratogain );
33 // volume
34 brass.controlChange( 128, volume );
35
36 for( int i; i < notes.size(); i++ )
37 {
38 play( 12 + notes[i], Math.random2f( .6, .9 ) );
39 300::ms => now;
40 }
41 }
42
43 // basic play function (add more arguments as needed)
44 fun void play( float note, float velocity )
45 {
46 // start the note
47 Std.mtof( note ) => brass.freq;
48 velocity => brass.noteOn;
49 }