Debian Codegraph @

examples/stk/mode-o-matic.ck

raw
1 //---------------|
2 // modal demo
3 // based off of mand-o-matic ( master plan )
4 // by : philipd
5 // by: Ge Wang ([email protected])
6 // Perry R. Cook ([email protected])
7 //------------------|
8 // our patch
9
10 ModalBar modey => JCRev r => Echo a => Echo b => Echo c => dac;
11
12 // set the gain
13 .95 => r.gain;
14 // set the reverb mix
15 .05 => r.mix;
16 // set max delay for echo
17 1000::ms => a.max => b.max => c.max;
18 // set delay for echo
19 750::ms => a.delay => b.delay => c.delay;
20 // set the initial effect mix
21 0.0 => a.mix => b.mix => c.mix;
22
23 <<< "preset:", modey.preset() >>>;
24
25 // shred to modulate the mix
26 fun void echo_Shred( )
27 {
28 0.0 => float decider => float mix => float old => float inc;
29
30 // time loop
31 while( true )
32 {
33 Math.random2f( 0, 1 ) => decider;
34 if( decider < .35 ) 0.0 => mix;
35 else if( decider < .55 ) .08 => mix;
36 else if( decider < .8 ) .5 => mix;
37 else .15 => mix;
38
39 // find the increment
40 (mix-old)/1000.0 => inc; 1000 => int n;
41 // time loop
42 while( n-- )
43 {
44 // set the mix for a, b, c
45 old + inc => old => a.mix => b.mix => c.mix;
46 1::ms => now;
47 }
48 // remember the old
49 mix => old;
50 // let time pass until the next iteration
51 Math.random2(2,6)::second => now;
52 }
53 }
54
55 // let echo shred go
56 spork ~ echo_Shred();
57
58 // scale
59 [ 0, 2, 4, 7, 9, 11 ] @=> int scale[];
60
61 // our main loop
62 while( true )
63 {
64 // presets
65 // note: Math.randomf() returns value between 0 and 1
66 if( Math.randomf() > 0.9 )
67 {
68 Math.random2( 0, 8 ) => modey.preset;
69 <<< "preset:", modey.preset() >>>;
70 }
71
72 // position
73 Math.random2f( 0.2, 0.8 ) => modey.strikePosition;
74 // frequency...
75 scale[Math.random2(0,scale.size()-1)] => int freq;
76 Std.mtof( 45 + Math.random2(0,4)*12 + freq ) => modey.freq;
77
78 // pluck it!
79 Math.random2f( 0.2, 0.6 ) => modey.strike;
80
81 // note: Math.randomf() returns value between 0 and 1
82 if( Math.randomf() > 0.8 )
83 { 500::ms => now; }
84 else if( Math.randomf() > .925 )
85 { 250::ms => now; }
86 else if( Math.randomf() > .05 )
87 { .125::second => now; }
88 else
89 {
90 1 => int i => int pick_dir;
91 // how many times
92 4 * Math.random2( 1, 5 ) => int pick;
93 0.0 => float pluck;
94 0.65 / pick => float inc;
95 // time loop
96 for( ; i < pick; i++ )
97 {
98 75::ms => now;
99 Math.random2f(.2,.3) + i*inc => pluck;
100 pluck => modey.stickHardness;
101 pluck + -.2 * pick_dir => modey.strike;
102 // simulate pluck direction
103 !pick_dir => pick_dir;
104 }
105 // let time pass for final pluck
106 75::ms => now;
107 }
108 }