summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/extra/filters.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/extra/filters.h')
-rw-r--r--apps/plugins/pdbox/PDa/extra/filters.h75
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
105typedef 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
115static 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;
139stable:
140 return 1;
141}
142
143
144
145
146
147
148#endif