[PD-cvs] pd/src builtins_dsp.c,1.1.2.28,1.1.2.29
Mathieu Bouchard
matju at users.sourceforge.net
Thu Jul 19 21:23:22 CEST 2007
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5053
Modified Files:
Tag: desiredata
builtins_dsp.c
Log Message:
cleanup
Index: builtins_dsp.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/builtins_dsp.c,v
retrieving revision 1.1.2.28
retrieving revision 1.1.2.29
diff -C2 -d -r1.1.2.28 -r1.1.2.29
*** builtins_dsp.c 19 Jul 2007 19:20:19 -0000 1.1.2.28
--- builtins_dsp.c 19 Jul 2007 19:23:20 -0000 1.1.2.29
***************
*** 2229,2233 ****
x->dim.os=1;
x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL, in, out1, out2, FFTW_ESTIMATE | FFTW_PRESERVE_INPUT);
! dsp_add(sigrfftw_perform,3,&x->plan,out2+1,n2-1);
dsp_add_zero(out1 + n2, n2);
dsp_add_zero(out2 + n2, n2);
--- 2229,2233 ----
x->dim.os=1;
x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL, in, out1, out2, FFTW_ESTIMATE | FFTW_PRESERVE_INPUT);
! dsp_add(sigrfftw_perform,3,&x->plan,out2+1,n2-1);
dsp_add_zero(out1 + n2, n2);
dsp_add_zero(out2 + n2, n2);
***************
*** 2239,2254 ****
float *in2 = sp[1]->v;
float *out = sp[2]->v;
! if (n < 4) {
! error("fft: minimum 4 points");
! return;
! } else {
! x->dim.n=n;
! x->dim.is=1;
! x->dim.os=1;
! x->plan = fftwf_plan_guru_split_dft_c2r(1, &(x->dim), 0, NULL,
! in1, in2, out, FFTW_ESTIMATE | FFTW_PRESERVE_INPUT);
! dsp_add_zero(in1+ n/2, n/2);
! dsp_add(sigrifftw_perform,3,&x->plan,in2,n2);
! }
}
static void sigfftw_setup() {
--- 2239,2249 ----
float *in2 = sp[1]->v;
float *out = sp[2]->v;
! if (n < 4) {error("fft: minimum 4 points"); return;}
! x->dim.n=n;
! x->dim.is=1;
! x->dim.os=1;
! x->plan = fftwf_plan_guru_split_dft_c2r(1, &(x->dim), 0, NULL, in1, in2, out, FFTW_ESTIMATE | FFTW_PRESERVE_INPUT);
! dsp_add_zero(in1+ n/2, n/2);
! dsp_add(sigrifftw_perform,3,&x->plan,in2,n2);
}
static void sigfftw_setup() {
***************
*** 2343,2348 ****
/* ---------------- hip~ - 1-pole 1-zero hipass filter. ----------------- */
struct t_hipctl {
! float c_x;
! float c_coef;
};
struct t_sighip : t_object {
--- 2338,2343 ----
/* ---------------- hip~ - 1-pole 1-zero hipass filter. ----------------- */
struct t_hipctl {
! float x;
! float coef;
};
struct t_sighip : t_object {
***************
*** 2361,2365 ****
x->sr = 44100;
x->ctl = &x->cspace;
! x->cspace.c_x = 0;
sighip_ft1(x, f);
x->a = 0;
--- 2356,2360 ----
x->sr = 44100;
x->ctl = &x->cspace;
! x->cspace.x = 0;
sighip_ft1(x, f);
x->a = 0;
***************
*** 2369,2375 ****
if (f < 0) f = 0;
x->hz = f;
! x->ctl->c_coef = 1 - f * (2 * 3.14159) / x->sr;
! if (x->ctl->c_coef < 0) x->ctl->c_coef = 0;
! else if (x->ctl->c_coef > 1) x->ctl->c_coef = 1;
}
static t_int *sighip_perform(t_int *w) {
--- 2364,2370 ----
if (f < 0) f = 0;
x->hz = f;
! x->ctl->coef = 1 - f * (2 * 3.14159) / x->sr;
! if (x->ctl->coef < 0) x->ctl->coef = 0;
! else if (x->ctl->coef > 1) x->ctl->coef = 1;
}
static t_int *sighip_perform(t_int *w) {
***************
*** 2378,2383 ****
t_hipctl *c = (t_hipctl *)w[3];
int n = (t_int)w[4];
! float last = c->c_x;
! float coef = c->c_coef;
if (coef < 1) {
for (int i = 0; i < n; i++) {
--- 2373,2378 ----
t_hipctl *c = (t_hipctl *)w[3];
int n = (t_int)w[4];
! float last = c->x;
! float coef = c->coef;
if (coef < 1) {
for (int i = 0; i < n; i++) {
***************
*** 2388,2395 ****
if (PD_BIGORSMALL(last))
last = 0;
! c->c_x = last;
} else {
for (int i = 0; i < n; i++) *out++ = *in++;
! c->c_x = 0;
}
return w+5;
--- 2383,2390 ----
if (PD_BIGORSMALL(last))
last = 0;
! c->x = last;
} else {
for (int i = 0; i < n; i++) *out++ = *in++;
! c->x = 0;
}
return w+5;
***************
*** 2401,2405 ****
}
static void sighip_clear(t_sighip *x, t_floatarg q) {
! x->cspace.c_x = 0;
}
void sighip_setup() {
--- 2396,2400 ----
}
static void sighip_clear(t_sighip *x, t_floatarg q) {
! x->cspace.x = 0;
}
void sighip_setup() {
***************
*** 2413,2418 ****
/* ---------------- lop~ - 1-pole lopass filter. ----------------- */
struct t_lopctl {
! float c_x;
! float c_coef;
};
struct t_siglop : t_object {
--- 2408,2413 ----
/* ---------------- lop~ - 1-pole lopass filter. ----------------- */
struct t_lopctl {
! float x;
! float coef;
};
struct t_siglop : t_object {
***************
*** 2431,2435 ****
x->sr = 44100;
x->ctl = &x->cspace;
! x->cspace.c_x = 0;
siglop_ft1(x, f);
x->a = 0;
--- 2426,2430 ----
x->sr = 44100;
x->ctl = &x->cspace;
! x->cspace.x = 0;
siglop_ft1(x, f);
x->a = 0;
***************
*** 2439,2448 ****
if (f < 0) f = 0;
x->hz = f;
! x->ctl->c_coef = f * (2 * 3.14159) / x->sr;
! if (x->ctl->c_coef > 1) x->ctl->c_coef = 1;
! if (x->ctl->c_coef < 0) x->ctl->c_coef = 0;
}
static void siglop_clear(t_siglop *x, t_floatarg q) {
! x->cspace.c_x = 0;
}
static t_int *siglop_perform(t_int *w) {
--- 2434,2443 ----
if (f < 0) f = 0;
x->hz = f;
! x->ctl->coef = f * (2 * 3.14159) / x->sr;
! if (x->ctl->coef > 1) x->ctl->coef = 1;
! if (x->ctl->coef < 0) x->ctl->coef = 0;
}
static void siglop_clear(t_siglop *x, t_floatarg q) {
! x->cspace.x = 0;
}
static t_int *siglop_perform(t_int *w) {
***************
*** 2451,2460 ****
t_lopctl *c = (t_lopctl *)w[3];
int n = (t_int)w[4];
! float last = c->c_x;
! float coef = c->c_coef;
float feedback = 1 - coef;
for (int i = 0; i < n; i++) last = *out++ = coef * *in++ + feedback * last;
if (PD_BIGORSMALL(last)) last = 0;
! c->c_x = last;
return w+5;
}
--- 2446,2455 ----
t_lopctl *c = (t_lopctl *)w[3];
int n = (t_int)w[4];
! float last = c->x;
! float coef = c->coef;
float feedback = 1 - coef;
for (int i = 0; i < n; i++) last = *out++ = coef * *in++ + feedback * last;
if (PD_BIGORSMALL(last)) last = 0;
! c->x = last;
return w+5;
}
***************
*** 2477,2483 ****
float x1;
float x2;
! float c_coef1;
! float c_coef2;
! float c_gain;
};
struct t_sigbp : t_object {
--- 2472,2478 ----
float x1;
float x2;
! float coef1;
! float coef2;
! float gain;
};
struct t_sigbp : t_object {
***************
*** 2521,2528 ****
if (oneminusr > 1.0f) oneminusr = 1.0f;
r = 1.0f - oneminusr;
! x->ctl->c_coef1 = 2.0f * sigbp_qcos(omega) * r;
! x->ctl->c_coef2 = - r * r;
! x->ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega);
! /* post("r %f, omega %f, coef1 %f, coef2 %f", r, omega, x->ctl->c_coef1, x->ctl->c_coef2); */
}
static void sigbp_ft1(t_sigbp *x, t_floatarg f) {sigbp_docoef(x, f, x->q);}
--- 2516,2523 ----
if (oneminusr > 1.0f) oneminusr = 1.0f;
r = 1.0f - oneminusr;
! x->ctl->coef1 = 2.0f * sigbp_qcos(omega) * r;
! x->ctl->coef2 = - r * r;
! x->ctl->gain = 2 * oneminusr * (oneminusr + r * omega);
! /* post("r %f, omega %f, coef1 %f, coef2 %f", r, omega, x->ctl->coef1, x->ctl->coef2); */
}
static void sigbp_ft1(t_sigbp *x, t_floatarg f) {sigbp_docoef(x, f, x->q);}
***************
*** 2536,2542 ****
float last = c->x1;
float prev = c->x2;
! float coef1 = c->c_coef1;
! float coef2 = c->c_coef2;
! float gain = c->c_gain;
for (int i = 0; i < n; i++) {
float output = *in++ + coef1 * last + coef2 * prev;
--- 2531,2537 ----
float last = c->x1;
float prev = c->x2;
! float coef1 = c->coef1;
! float coef2 = c->coef2;
! float gain = c->gain;
for (int i = 0; i < n; i++) {
float output = *in++ + coef1 * last + coef2 * prev;
More information about the Pd-cvs
mailing list