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