Debian Codegraph @

examples/stk/stif-o-karp.ck

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