1declare name "lowcut"; 2declare version "1.0"; 3declare author "Grame"; 4declare license "BSD"; 5declare 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 14import("music.lib"); 15 16 17 18//------------------- low-frequency shelving cut (table 2.3) -------------------- 19 20V0(g) = pow(10,g/-20.0); 21K(fc) = tan(PI*fc/SR); 22square(x) = x*x; 23denom(fc,g) = 1 + sqrt(2*V0(g))*K(fc) + V0(g)*square(K(fc)); 24 25lfcut(fc, g) = TF2( (1 + sqrt(2)*K(fc) + square(K(fc))) / denom(fc,g), 26 2 * (square(K(fc)) - 1) / denom(fc,g), 27 (1 - sqrt(2)*K(fc) + square(K(fc))) / denom(fc,g), 28 2 * (V0(g)*square(K(fc)) - 1) / denom(fc,g), 29 (1 - sqrt(2*V0(g))*K(fc) + V0(g)*square(K(fc))) / denom(fc,g) 30 ); 31 32 33//------------------------------ User Interface ----------------------------------- 34 35freq = hslider("freq", 1000, 20, 20000, 0.1); 36att = hslider("attenuation (db)", 0, -96, 10, 0.1); 37 38 39//----------------------------------- Process ------------------------------------- 40 41process = vgroup("low-freq shelving cut", lfcut(freq,att)); 42 43