Debian Codegraph @

examples/stk/voic-o-form.ck

raw
1 // music for replicants
2
3 // patch
4 VoicForm voc=> JCRev r => Echo a => Echo b => Echo c => dac;
5
6 // settings
7 220.0 => voc.freq;
8 0.95 => voc.gain;
9 .8 => r.gain;
10 .2 => r.mix;
11 1000::ms => a.max => b.max => c.max;
12 750::ms => a.delay => b.delay => c.delay;
13 .50 => a.mix => b.mix => c.mix;
14
15 // shred to modulate the mix
16 fun void vecho_Shred( )
17 {
18 0.0 => float decider;
19 0.0 => float mix;
20 0.0 => float old;
21 0.0 => float inc;
22 0 => int n;
23
24 // time loop
25 while( true )
26 {
27 Math.random2f(0.0,1.0) => decider;
28 if( decider < .3 ) 0.0 => mix;
29 else if( decider < .6 ) .08 => mix;
30 else if( decider < .8 ) .5 => mix;
31 else .15 => mix;
32
33 // find the increment
34 (mix-old)/1000.0 => inc;
35 1000 => n;
36 while( n-- )
37 {
38 old + inc => old;
39 if( old < 0 ) 0 => old;
40 old => a.mix => b.mix => c.mix;
41 1::ms => now;
42 }
43 mix => old;
44 Math.random2(2,6)::second => now;
45 }
46 }
47
48 // let echo shred go
49 spork ~ vecho_Shred();
50 0.5 => voc.loudness;
51 0.01 => voc.vibratoGain;
52
53 // scale
54 [ 0, 2, 4, 7, 9 ] @=> int scale[];
55
56 // our main time loop
57 while( true )
58 {
59 2 * Math.random2( 0,2 ) => int bphon;
60 bphon => voc.phonemeNum;
61 Math.random2f( 0.6, 0.8 ) => voc.noteOn;
62
63 // note: Math.randomf() returns value between 0 and 1
64 if( Math.randomf() > 0.85 )
65 { 1000::ms => now; }
66 else if( Math.randomf() > .85 )
67 { 500::ms => now; }
68 else if( Math.randomf() > .1 )
69 { .250::second => now; }
70 else
71 {
72 0 => int i;
73 4 * Math.random2( 1, 4 ) => int pick;
74 0 => int pick_dir;
75 0.0 => float pluck;
76
77 for( ; i < pick; i++ )
78 {
79 bphon + 1 * pick_dir => voc.phonemeNum;
80 Math.random2f(.4,.6) + i*.035 => pluck;
81 pluck + 0.0 * pick_dir => voc.noteOn;
82 !pick_dir => pick_dir;
83 250::ms => now;
84 }
85 }
86
87 // pentatonic
88 scale[Math.random2(0,scale.size()-1)] => int freq;
89 Std.mtof( ( 45 + Math.random2(0,2) * 12 + freq ) ) => voc.freq;
90 }