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/equalizer.c | |
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/equalizer.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/extra/equalizer.c | 94 |
1 files changed, 1 insertions, 93 deletions
diff --git a/apps/plugins/pdbox/PDa/extra/equalizer.c b/apps/plugins/pdbox/PDa/extra/equalizer.c index 1d21c4087c..743832302b 100644 --- a/apps/plugins/pdbox/PDa/extra/equalizer.c +++ b/apps/plugins/pdbox/PDa/extra/equalizer.c | |||
@@ -83,96 +83,4 @@ void equalizer_setup(void) | |||
83 | class_addfloat(equ_class,equ_float); | 83 | class_addfloat(equ_class,equ_float); |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | |||
88 | |||
89 | |||
90 | /* (C) Guenter Geiger <geiger@epy.co.at> */ | ||
91 | |||
92 | |||
93 | /* | ||
94 | |||
95 | These filter coefficients computations are taken from | ||
96 | http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt | ||
97 | |||
98 | written by Robert Bristow-Johnson | ||
99 | |||
100 | */ | ||
101 | |||
102 | #include "m_pd.h" | ||
103 | #ifdef NT | ||
104 | #pragma warning( disable : 4244 ) | ||
105 | #pragma warning( disable : 4305 ) | ||
106 | #endif | ||
107 | #include <math.h> | ||
108 | #include "filters.h" | ||
109 | |||
110 | |||
111 | |||
112 | /* ------------------- equ ----------------------------*/ | ||
113 | static t_class *equ_class; | ||
114 | |||
115 | void equ_bang(t_rbjfilter *x) | ||
116 | { | ||
117 | t_atom at[5]; | ||
118 | t_float omega = e_omega(x->x_freq,x->x_rate); | ||
119 | t_float alpha = e_alpha(x->x_bw*0.01,omega); | ||
120 | t_float b0 = 1 + alpha*e_A(x->x_gain); | ||
121 | t_float b1 = -2.*cos(omega); | ||
122 | t_float b2 = 1 - alpha*e_A(x->x_gain); | ||
123 | t_float a0 = 1 + alpha/e_A(x->x_gain); | ||
124 | t_float a1 = -2.*cos(omega); | ||
125 | t_float a2 = 1 - alpha/e_A(x->x_gain); | ||
126 | |||
127 | /* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw);*/ | ||
128 | |||
129 | if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) { | ||
130 | post("equ: filter unstable -> resetting"); | ||
131 | a0=1.;a1=0.;a2=0.; | ||
132 | b0=1.;b1=0.;b2=0.; | ||
133 | } | ||
134 | |||
135 | SETFLOAT(at,-a1/a0); | ||
136 | SETFLOAT(at+1,-a2/a0); | ||
137 | SETFLOAT(at+2,b0/a0); | ||
138 | SETFLOAT(at+3,b1/a0); | ||
139 | SETFLOAT(at+4,b2/a0); | ||
140 | |||
141 | outlet_list(x->x_obj.ob_outlet,&s_list,5,at); | ||
142 | } | ||
143 | |||
144 | |||
145 | void equ_float(t_rbjfilter *x,t_floatarg f) | ||
146 | { | ||
147 | x->x_freq = f; | ||
148 | equ_bang(x); | ||
149 | } | ||
150 | |||
151 | |||
152 | static void *equ_new(t_floatarg f,t_floatarg g,t_floatarg bw) | ||
153 | { | ||
154 | t_rbjfilter *x = (t_rbjfilter *)pd_new(equ_class); | ||
155 | |||
156 | x->x_rate = 44100.0; | ||
157 | outlet_new(&x->x_obj,&s_float); | ||
158 | floatinlet_new(&x->x_obj, &x->x_gain); | ||
159 | floatinlet_new(&x->x_obj, &x->x_bw); | ||
160 | if (f > 0.) x->x_freq = f; | ||
161 | if (bw > 0.) x->x_bw = bw; | ||
162 | if (g != 0.) x->x_gain = g; | ||
163 | return (x); | ||
164 | } | ||
165 | |||
166 | |||
167 | void equalizer_setup(void) | ||
168 | { | ||
169 | equ_class = class_new(gensym("equalizer"), (t_newmethod)equ_new, 0, | ||
170 | sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); | ||
171 | class_addbang(equ_class,equ_bang); | ||
172 | class_addfloat(equ_class,equ_float); | ||
173 | } | ||
174 | |||
175 | |||
176 | |||
177 | |||
178 | |||