Debian Codegraph @

examples/deep/follower.ck

raw
1 //-----------------------------------------------------------------------------
2 // name: follower.ck
3 // desc: a simple envelope follower
4 //
5 // author: Perry R. Cook
6 /*-----------------------------------------------------------------------------
7 Hi all. I keep meaning to post to this list about the under-exploited
8 feature that all unit generators have, in that you can cause their inputs
9 to multiply rather than add. As an example, here's a simple power
10 envelope follower that doesn't require sample-level chuck intervention. A
11 gain UG is used to square the incoming A/D signal (try it on your built-in
12 mic), then a OnePole UG is used as a "leaky integrator" to keep a running
13 estimate of the signal power. The main loop wakes up each 100 ms and
14 checks the power, and prints out a message if it's over a certain level.
15 You might need to change the threshold, but you get the idea.
16 -----------------------------------------------------------------------------*/
17
18 // patch
19 adc => Gain g => OnePole p => blackhole;
20 // square the input
21 adc => g;
22 // multiply
23 3 => g.op;
24
25 // set pole position
26 0.99 => p.pole;
27
28 // loop on
29 while( true )
30 {
31 if( p.last() > 0.01 )
32 {
33 <<< "BANG!!" >>>;
34 80::ms => now;
35 }
36 20::ms => now;
37 }