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