Debian Codegraph @

examples/analysis/tracking/harm.ck

raw
1 //--
2 // name: harm.ck
3 // desc: using Tracking and Smacking to harmonize
4 //
5 // author: Rebecca Fiebrink + Ge Wang
6 // date: 2007
7 //--
8
9
10 // synthesis
11 BlitSaw s => JCRev r => dac;
12 4 => s.harmonics;
13
14 // set reverb mix
15 .05 => r.mix;
16 // possible hamonizing intervals
17 [ 3-24, 4-12, 7, 9+12 ] @=> int harms[];
18 float the_harm;
19
20 // interpolate
21 float target_freq, curr_freq, target_gain, curr_gain;
22 spork ~ ramp_stuff();
23 spork ~ smack_handler();
24
25 // go for it
26 while( true )
27 {
28 // wait for analysis event
29 Tracking.the_event => now;
30
31 // set freq
32 Tracking.the_freq * Math.pow(1.059, the_harm) => target_freq;
33 // set gain
34 Tracking.the_gain => target_gain;
35 }
36
37 // interpolation
38 fun void ramp_stuff()
39 {
40 // mysterious 'slew'
41 0.025 => float slew;
42
43 // infinite time loop
44 while( true )
45 {
46 (target_freq - curr_freq) * 1 * slew + curr_freq => curr_freq => s.freq;
47 (target_gain - curr_gain) * .25 * slew + curr_gain => curr_gain => s.gain;
48 0.0025::second => now;
49 }
50 }
51
52 // handles smack
53 fun void smack_handler()
54 {
55 // go
56 while( true )
57 {
58 // wait
59 Smacking.the_event => now;
60
61 // choose random interval
62 harms[Math.random2(0,harms.size()-1)] => the_harm;
63 // set freq
64 Tracking.the_freq * Math.pow(1.059, the_harm) => target_freq;
65 // print
66 <<< "new interval:", the_harm >>>;
67 }
68 }