Debian Codegraph @

examples/stk/hevymetl-algo3.ck

raw
1 // name: hevymetl-algo3.ck
2 // desc: demo of STK FM HevyMetl (Algorithm 3)
3 //
4 // name: Perry R. Cook
5 // date: June 2021, for REPAIRATHON 2021
6
7 // patch
8 HevyMetl h => NRev r => dac;
9 // reverb mix
10 0.05 => r.mix;
11 // set delay
12 h => Delay d => d => r;
13 // quarter note length
14 0.25::second => dur T;
15 // delay
16 4*T => d.max => d.delay;
17 // feedback gain
18 0.25 => d.gain;
19
20 // time loop
21 while( true )
22 {
23 // LFO depth
24 0.0 => h.lfoDepth;
25
26 // play notes
27 playNote( 66,2*T );
28 playNote( 66,T );
29 playNote( 66,T );
30 playNote( 67,T );
31 playNote( 67,3*T );
32 playNote( 64,T );
33
34 // from time to time...
35 if( maybe*maybe ) playNote(64+2*Math.random2(0,5),2*T);
36 else playNote(64,2*T);
37
38 playNote(66,5*T);
39
40 riff();
41 }
42
43 fun void playNote( int note, dur dure )
44 {
45 Std.mtof(note) => h.freq;
46 1 => h.noteOn;
47 0.9*(dure) => now;
48 1 => h.noteOff;
49 0.1*(dure) => now;
50 }
51
52 fun void riff()
53 {
54 [74,69,66,72,67,62,71,67,62,69] @=> int notes[];
55 [1,1,1,2,1,1,2,1,1,5] @=> int durs[];
56 for (int i; i < notes.cap(); i++)
57 {
58 Std.mtof(notes[i]) => h.freq;
59 1 => h.noteOn;
60 if (i == notes.cap()-1) 0.3 => h.lfoDepth;
61 durs[i]*T => now;
62 }
63 1 => h.noteOff;
64 }