157b0c1633ae270ab8b8fe6681471bff4de9a0c7
[Faustine.git] / interpretor / faust-0.9.47mr3 / examples / bandfilter.dsp
1 declare name "bandfilter";
2 declare version "1.0";
3 declare author "Grame";
4 declare license "BSD";
5 declare copyright "(c)GRAME 2006";
6
7 import("math.lib");
8 import("music.lib");
9
10 //---------------------second order filter--------------------------
11 // filter(Q,F,G)
12 // Q : quality factor [1..100]
13 // F : frequency (Hz)
14 // G : gain [0..1]
15 //------------------------------------------------------------------
16
17 filter(Q,F,G) = TF2( (1 + K/Q + K*K) / D,
18 2 * (K*K - 1) / D,
19 (1 - K/Q + K*K) / D,
20 2 * (K*K - 1) / D,
21 (1 - V*K/Q + K*K) / D
22 )
23 with {
24 V = db2linear(G);
25 K = tan(PI*F/SR);
26 D = 1 + V*K/Q + K*K;
27 };
28
29
30
31 //--------------- Band Filter with user interface ------------------
32 // bandfilter(F)
33 // F : default frequency (Hz)
34 //
35 //------------------------------------------------------------------
36
37 bandfilter(F) = filter( nentry("Q factor [style:knob]",50,0.1,100,0.1),
38 nentry("freq [unit:Hz][style:knob]", F, 20, 20000, 1),
39 0 - vslider("gain [unit:dB]", 0, -50, 50, 0.1)
40 );
41
42
43
44 //------------------------- Process --------------------------------
45
46 process = vgroup("Bandfilter", bandfilter(1000));
47