Debian Codegraph @

examples/stk/wurley.ck

raw
1 // even more music for replicants
2
3 // patch
4 Wurley voc=> JCRev r => dac;
5
6 // initial settings
7 220.0 => voc.freq;
8 0.95 => voc.gain;
9 .8 => r.gain;
10 .1 => r.mix;
11
12 // scale
13 [ 0, 3, 7, 8, 11 ] @=> int scale[];
14
15 // our main time loop
16 while( true )
17 {
18 // scale
19 scale[Math.random2(0,scale.size()-1)] => int freq;
20 Std.mtof( ( 45 + Math.random2(0,1) * 12 + freq ) ) => voc.freq;
21 Math.random2f( 0.6, 0.8 ) => voc.noteOn;
22
23 // note: Math.randomf() returns value between 0 and 1
24 if( Math.randomf() > 0.9 )
25 {
26 // 1000::ms => now;
27 repeat( 100 )
28 {
29 voc.freq() * 1.01 => voc.freq;
30 10::ms => now;
31 }
32 }
33 else if( Math.randomf() > .75 )
34 {
35 // 500::ms => now;
36 repeat( 50 )
37 {
38 voc.freq() * .99 => voc.freq;
39 10::ms => now;
40 }
41 }
42 else if( Math.randomf() > .1 )
43 {
44 250::ms => now;
45
46 }
47 else
48 {
49 0 => int i;
50 2 * Math.random2( 1, 3 ) => int pick;
51 0 => int pick_dir;
52 0.0 => float pluck;
53
54 for( ; i < pick; i++ )
55 {
56 Math.random2f(.4,.6) + i*.035 => pluck;
57 pluck + 0.03 * (i * pick_dir) => voc.noteOn;
58 !pick_dir => pick_dir;
59 250::ms => now;
60 }
61 }
62 }