diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
commit | 526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch) | |
tree | 22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/extra/filters.h | |
parent | 4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff) | |
download | rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip |
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/extra/filters.h')
-rw-r--r-- | apps/plugins/pdbox/PDa/extra/filters.h | 75 |
1 files changed, 1 insertions, 74 deletions
diff --git a/apps/plugins/pdbox/PDa/extra/filters.h b/apps/plugins/pdbox/PDa/extra/filters.h index 72d997e425..8a91f75073 100644 --- a/apps/plugins/pdbox/PDa/extra/filters.h +++ b/apps/plugins/pdbox/PDa/extra/filters.h | |||
@@ -72,77 +72,4 @@ stable: | |||
72 | 72 | ||
73 | 73 | ||
74 | #endif | 74 | #endif |
75 | /* | 75 | |
76 | |||
77 | These filter coefficients computations are taken from | ||
78 | http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt | ||
79 | |||
80 | written by Robert Bristow-Johnson | ||
81 | |||
82 | */ | ||
83 | |||
84 | |||
85 | #ifndef __GGEE_FILTERS_H__ | ||
86 | #define __GGEE_FILTERS_H__ | ||
87 | |||
88 | |||
89 | |||
90 | #ifndef M_PI | ||
91 | #define M_PI 3.141593f | ||
92 | #endif | ||
93 | |||
94 | |||
95 | #include <math.h> | ||
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))) | ||
101 | |||
102 | |||
103 | |||
104 | |||
105 | typedef struct _rbjfilter | ||
106 | { | ||
107 | t_object x_obj; | ||
108 | t_float x_rate; | ||
109 | t_float x_freq; | ||
110 | t_float x_gain; | ||
111 | t_float x_bw; | ||
112 | } t_rbjfilter; | ||
113 | |||
114 | |||
115 | static int check_stability(t_float fb1, | ||
116 | t_float fb2, | ||
117 | t_float ff1, | ||
118 | t_float ff2, | ||
119 | t_float ff3) | ||
120 | { | ||
121 | float discriminant = fb1 * fb1 + 4 * fb2; | ||
122 | |||
123 | if (discriminant < 0) /* imaginary roots -- resonant filter */ | ||
124 | { | ||
125 | /* they're conjugates so we just check that the product | ||
126 | is less than one */ | ||
127 | if (fb2 >= -1.0f) goto stable; | ||
128 | } | ||
129 | else /* real roots */ | ||
130 | { | ||
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) | ||
136 | goto stable; | ||
137 | } | ||
138 | return 0; | ||
139 | stable: | ||
140 | return 1; | ||
141 | } | ||
142 | |||
143 | |||
144 | |||
145 | |||
146 | |||
147 | |||
148 | #endif | ||