summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/extra/highpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/extra/highpass.c')
-rw-r--r--apps/plugins/pdbox/PDa/extra/highpass.c91
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
111static t_class *highpass_class;
112
113void 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
143void highpass_float(t_rbjfilter *x,t_floatarg f)
144{
145 x->x_freq = f;
146 highpass_bang(x);
147}
148
149
150static 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
164void 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