Refactoring of Signal class by adding a rate class.
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / examples / lowboost.dsp
1 declare name "lowboost";
2 declare version "1.0";
3 declare author "Grame";
4 declare license "BSD";
5 declare copyright "(c)GRAME 2006";
6
7 //------------------------------------------------------------------
8 // DAFX, Digital Audio Effects (Wiley ed.)
9 // chapter 2 : filters
10 // section 2.3 : Equalizers
11 // page 53 : second order shelving filter design
12 //------------------------------------------------------------------
13
14 import("music.lib");
15
16
17 //------------------- low-frequency shelving boost (table 2.3) --------------------
18
19 V0(g) = pow(10,g/20.0);
20 K(fc) = tan(PI*fc/SR);
21 square(x) = x*x;
22 denom(fc) = 1 + sqrt(2)*K(fc) + square(K(fc));
23
24 lfboost(fc, g) = TF2( (1 + sqrt(2*V0(g))*K(fc) + V0(g)*square(K(fc))) / denom(fc),
25 2 * (V0(g)*square(K(fc)) - 1) / denom(fc),
26 (1 - sqrt(2*V0(g))*K(fc) + V0(g)*square(K(fc))) / denom(fc),
27 2 * (square(K(fc)) - 1) / denom(fc),
28 (1 - sqrt(2)*K(fc) + square(K(fc))) / denom(fc)
29 );
30
31
32 //------------------------------ User Interface -----------------------------------
33
34 freq = hslider("[1]freq [unit:Hz][style:knob]", 1000, 20, 20000, 0.1);
35 gain = hslider("[2]gain [unit:dB][style:knob]", 0, -20, 20, 0.1);
36
37
38 //----------------------------------- Process -------------------------------------
39
40 process = vgroup("low-freq shelving boost", lfboost(freq,gain));
41