summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/extra/bandpass.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
commit526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch)
tree22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/extra/bandpass.c
parent4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff)
downloadrockbox-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/bandpass.c')
-rw-r--r--apps/plugins/pdbox/PDa/extra/bandpass.c87
1 files changed, 1 insertions, 86 deletions
diff --git a/apps/plugins/pdbox/PDa/extra/bandpass.c b/apps/plugins/pdbox/PDa/extra/bandpass.c
index 6de56d6174..127a1eee06 100644
--- a/apps/plugins/pdbox/PDa/extra/bandpass.c
+++ b/apps/plugins/pdbox/PDa/extra/bandpass.c
@@ -84,89 +84,4 @@ void bandpass_setup(void)
84 84
85 85
86 86
87 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/* ------------------- bandpass ----------------------------*/
109
110static t_class *bandpass_class;
111
112void bandpass_bang(t_rbjfilter *x)
113{
114 t_atom at[5];
115 t_float omega = e_omega(x->x_freq,x->x_rate);
116 t_float alpha = e_alpha(x->x_bw* 0.01,omega);
117 t_float b1 = 0.;
118 t_float b0 = alpha;
119 t_float b2 = -alpha;
120 t_float a0 = 1 + alpha;
121 t_float a1 = -2.*cos(omega);
122 t_float a2 = 1 - alpha;
123
124/* post("bang %f %f %f",x->x_freq, x->x_gain, x->x_bw); */
125
126 if (!check_stability(-a1/a0,-a2/a0,b0/a0,b1/a0,b2/a0)) {
127 post("bandpass: filter unstable -> resetting");
128 a0=1.;a1=0.;a2=0.;
129 b0=1.;b1=0.;b2=0.;
130 }
131
132 SETFLOAT(at,-a1/a0);
133 SETFLOAT(at+1,-a2/a0);
134 SETFLOAT(at+2,b0/a0);
135 SETFLOAT(at+3,b1/a0);
136 SETFLOAT(at+4,b2/a0);
137
138 outlet_list(x->x_obj.ob_outlet,&s_list,5,at);
139}
140
141
142void bandpass_float(t_rbjfilter *x,t_floatarg f)
143{
144 x->x_freq = f;
145 bandpass_bang(x);
146}
147
148
149static void *bandpass_new(t_floatarg f,t_floatarg bw)
150{
151 t_rbjfilter *x = (t_rbjfilter *)pd_new(bandpass_class);
152
153 x->x_rate = 44100.0;
154 outlet_new(&x->x_obj,&s_float);
155/* floatinlet_new(&x->x_obj, &x->x_gain); */
156 floatinlet_new(&x->x_obj, &x->x_bw);
157 if (f > 0.) x->x_freq = f;
158 if (bw > 0.) x->x_bw = bw;
159 return (x);
160}
161
162
163void bandpass_setup(void)
164{
165 bandpass_class = class_new(gensym("bandpass"), (t_newmethod)bandpass_new, 0,
166 sizeof(t_rbjfilter), 0,A_DEFFLOAT,A_DEFFLOAT,0);
167 class_addbang(bandpass_class,bandpass_bang);
168 class_addfloat(bandpass_class,bandpass_float);
169}
170
171
172