3 These filter coefficients computations are taken from
4 http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
6 written by Robert Bristow-Johnson
11 #ifndef __GGEE_FILTERS_H__
12 #define __GGEE_FILTERS_H__
17 #define M_PI 3.141593f
22 #define LN2 0.69314718
23 #define e_A(g) (pow(10,(g/40.)))
24 #define e_omega(f,r) (2.0*M_PI*f/r)
25 #define e_alpha(bw,omega) (sin(omega)*sinh(LN2/2. * bw * omega/sin(omega)))
26 #define e_beta(a,S) (sqrt((a*a + 1)/(S) - (a-1)*(a-1)))
31 typedef struct _rbjfilter
41 static int check_stability(t_float fb1
,
47 float discriminant
= fb1
* fb1
+ 4 * fb2
;
49 if (discriminant
< 0) /* imaginary roots -- resonant filter */
51 /* they're conjugates so we just check that the product
53 if (fb2
>= -1.0f
) goto stable
;
57 /* check that the parabola 1 - fb1 x - fb2 x^2 has a
58 vertex between -1 and 1, and that it's nonnegative
59 at both ends, which implies both roots are in [1-,1]. */
60 if (fb1
<= 2.0f
&& fb1
>= -2.0f
&&
61 1.0f
- fb1
-fb2
>= 0 && 1.0f
+ fb1
- fb2
>= 0)
77 These filter coefficients computations are taken from
78 http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
80 written by Robert Bristow-Johnson
85 #ifndef __GGEE_FILTERS_H__
86 #define __GGEE_FILTERS_H__
91 #define M_PI 3.141593f
96 #define LN2 0.69314718
97 #define e_A(g) (pow(10,(g/40.)))
98 #define e_omega(f,r) (2.0*M_PI*f/r)
99 #define e_alpha(bw,omega) (sin(omega)*sinh(LN2/2. * bw * omega/sin(omega)))
100 #define e_beta(a,S) (sqrt((a*a + 1)/(S) - (a-1)*(a-1)))
105 typedef struct _rbjfilter
115 static int check_stability(t_float fb1
,
121 float discriminant
= fb1
* fb1
+ 4 * fb2
;
123 if (discriminant
< 0) /* imaginary roots -- resonant filter */
125 /* they're conjugates so we just check that the product
127 if (fb2
>= -1.0f
) goto stable
;
129 else /* real roots */
131 /* check that the parabola 1 - fb1 x - fb2 x^2 has a
132 vertex between -1 and 1, and that it's nonnegative
133 at both ends, which implies both roots are in [1-,1]. */
134 if (fb1
<= 2.0f
&& fb1
>= -2.0f
&&
135 1.0f
- fb1
-fb2
>= 0 && 1.0f
+ fb1
- fb2
>= 0)