Debian Codegraph @

examples/special/Dyno-compress.ck

raw
1 //--------------------------------------|
2 // Dyno demo 2: "Compressor? I didn't even touch 'er!"
3 // Takes a silly little plucked string demo and runs it through a
4 // compressor to enhance sustain. (Ostensibly.) Note that there
5 // are many other (better) reasons to use compressors.
6 //
7 // authors: Matt Hoffman (mdhoffma at cs.princeton.edu)
8 //--------------------------------------|
9
10 // plucked string, dynamics processor, reverb, dac.
11 StifKarp m => Dyno d => JCRev r => dac;
12
13 // set reverb params
14 0.75 => r.gain;
15 0.01 => r.mix;
16
17 // set dyno to default compress mode
18 d.compress();
19 // set release time to be quite long to enhance sustain
20 2000::ms => d.releaseTime;
21 // set threshold to be a bit lower for more pronounced effect.
22 0.2 => d.thresh;
23 // set slope (in dB) above the threshold to 1/3 of what it would naturally be
24 0.33 => d.slopeAbove;
25 // compensate for the gain reduction
26 2 => d.gain;
27
28 // set plucked string params
29 0.1 => m.pickupPosition;
30 0.0 => m.sustain;
31 0.0 => m.stretch;
32
33 // go
34 while(true)
35 {
36 // play a random note
37 Std.mtof( Math.random2(60, 90) ) => m.freq;
38
39 // twice
40 repeat( 2 )
41 {
42 // say whether this pluck is compressed or not
43 if(d.op() < 0)
44 <<< "uncompressed" >>>;
45 else
46 <<< "compressed" >>>;
47
48 0.5 => m.pluck;
49 2000::ms => now;
50
51 // make the next note compressed if this one wasn't, or vice versa
52 -d.op() => d.op;
53 }
54 }