Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6028
Modified Files:
Tag: devel_0_37
d_fft.c
Log Message:
cleanup for fftw (aligned signals)
Index: d_fft.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/d_fft.c,v
retrieving revision 1.1.1.1.16.5
retrieving revision 1.1.1.1.16.6
diff -C2 -d -r1.1.1.1.16.5 -r1.1.1.1.16.6
*** d_fft.c 8 Oct 2004 17:58:27 -0000 1.1.1.1.16.5
--- d_fft.c 9 Oct 2004 16:37:36 -0000 1.1.1.1.16.6
***************
*** 269,278 ****
fftwf_plan plan;
- t_int bins;
fftwf_iodim dim;
- t_sample * inreal;
- t_sample * inimag;
- t_sample * outreal;
- t_sample * outimag;
} t_sigfftw;
--- 269,273 ----
***************
*** 299,306 ****
static void sigfftw_free(t_sigfftw * x)
{
- fftwf_free(x->inreal);
- fftwf_free(x->inimag);
- fftwf_free(x->outreal);
- fftwf_free(x->outimag);
fftwf_destroy_plan(x->plan);
}
--- 294,297 ----
***************
*** 308,315 ****
static void sigifftw_free(t_sigfftw * x)
{
- fftwf_free(x->inreal);
- fftwf_free(x->inimag);
- fftwf_free(x->outreal);
- fftwf_free(x->outimag);
fftwf_destroy_plan(x->plan);
}
--- 299,302 ----
***************
*** 318,335 ****
{
t_sigfftw * x =(t_sigfftw *) w[1];
- t_sample * in1 =(t_sample *) w[2];
- t_sample * in2 =(t_sample *) w[3];
- t_sample * out1 =(t_sample *) w[4];
- t_sample * out2 =(t_sample *) w[5];
- t_int n =(t_int) w[6];
- //prepare, execute and output results
- memcpy(x->inreal,in1,(sizeof(t_sample) * x->bins));
- memcpy(x->inimag,in2,(sizeof(t_sample) * x->bins));
fftwf_execute(x->plan);
- memcpy(out1,x->outreal,(sizeof(t_sample) * x->bins));
- memcpy(out2,x->outimag,(sizeof(t_sample) * x->bins));
! return (w+7);
}
--- 305,312 ----
{
t_sigfftw * x =(t_sigfftw *) w[1];
fftwf_execute(x->plan);
! return (w+2);
}
***************
*** 337,357 ****
{
t_sigfftw * x =(t_sigfftw *) w[1];
- t_sample * in1 =(t_sample *) w[2];
- t_sample * in2 =(t_sample *) w[3];
- t_sample * out1 =(t_sample *) w[4];
- t_sample * out2 =(t_sample *) w[5];
- t_int n =(t_int) w[6];
- //prepare, execute and output results
- memcpy(x->inreal,in1,(sizeof(t_sample) * x->bins));
- memcpy(x->inimag,in2,(sizeof(t_sample) * x->bins));
fftwf_execute(x->plan);
- memcpy(out1,x->outreal,(sizeof(t_sample) * x->bins));
- memcpy(out2,x->outimag,(sizeof(t_sample) * x->bins));
! return (w+7);
}
! static void sigfftw_dspx(t_sigfftw *x, t_signal **sp, t_int *(*f)(t_int *w))
{
int n = sp[0]->s_n;
--- 314,324 ----
{
t_sigfftw * x =(t_sigfftw *) w[1];
fftwf_execute(x->plan);
! return (w+2);
}
! static void sigfftw_dsp(t_sigfftw *x, t_signal **sp)
{
int n = sp[0]->s_n;
***************
*** 360,387 ****
float *out1 = sp[2]->s_vec;
float *out2 = sp[3]->s_vec;
!
! //prepare the fft
! x->bins=n;
! x->inreal = fftwf_malloc(sizeof(t_sample) * x->bins);
! x->inimag = fftwf_malloc(sizeof(t_sample) * x->bins);
! x->outreal = fftwf_malloc(sizeof(t_sample) * x->bins);
! x->outimag = fftwf_malloc(sizeof(t_sample) * x->bins);
x->dim.n=n;
x->dim.is=1;
x->dim.os=1;
! x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, x->inimag,
! x->inreal, x->outimag, x->outreal,
! FFTW_MEASURE);
! dsp_add(f, 6, x, in1, in2, out1, out2, n);
! }
!
! static void sigfftw_dsp(t_sigfftw *x, t_signal **sp)
! {
! sigfftw_dspx(x, sp, sigfftw_perform);
}
static void sigifftw_dsp(t_sigfftw *x, t_signal **sp)
{
! sigfftw_dspx(x, sp, sigifftw_perform);
}
--- 327,353 ----
float *out1 = sp[2]->s_vec;
float *out2 = sp[3]->s_vec;
!
x->dim.n=n;
x->dim.is=1;
x->dim.os=1;
! x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, in1,
! in2, out1, out2, FFTW_MEASURE);
! dsp_add(sigfftw_perform, 1, x);
}
static void sigifftw_dsp(t_sigfftw *x, t_signal **sp)
{
! int n = sp[0]->s_n;
! float *in1 = sp[0]->s_vec;
! float *in2 = sp[1]->s_vec;
! float *out1 = sp[2]->s_vec;
! float *out2 = sp[3]->s_vec;
!
! x->dim.n=n;
! x->dim.is=1;
! x->dim.os=1;
! x->plan = fftwf_plan_guru_split_dft(1, &(x->dim), 0, NULL, in2,
! in1, out2, out1, FFTW_MEASURE);
! dsp_add(sigfftw_perform, 1, x);
}
***************
*** 412,427 ****
typedef struct rfftw
{
! t_object x_obj;
float x_f;
!
fftwf_plan plan;
- t_int bins;
fftwf_iodim dim;
- t_sample * infft;
- t_sample * outreal;
- t_sample * outimag;
} t_sigrfftw;
- //constructor
static void *sigrfftw_new(void)
{
--- 378,388 ----
typedef struct rfftw
{
! t_object x_obj;
float x_f;
!
fftwf_plan plan;
fftwf_iodim dim;
} t_sigrfftw;
static void *sigrfftw_new(void)
{
***************
*** 433,446 ****
}
- //destructor
static void sigrfftw_free(t_sigrfftw *x)
{
- fftwf_free(x->infft);
- fftwf_free(x->outreal);
- fftwf_free(x->outimag);
fftwf_destroy_plan(x->plan);
}
! //we don't want to return the complex conjugated result of the fft
static void sigrfftw_invert(t_sample * s, t_int n)
{
--- 394,406 ----
}
static void sigrfftw_free(t_sigrfftw *x)
{
fftwf_destroy_plan(x->plan);
}
! /*
! * for compatibility reasons with the mayer fft, we'll have to invert
! * some samples ... this is ugly, but someone might rely on that ...
! */
static void sigrfftw_invert(t_sample * s, t_int n)
{
***************
*** 455,471 ****
{
t_sigrfftw * x =(t_sigrfftw *) w[1];
- t_sample * in1 =(t_sample *) w[2];
- t_sample * out1 =(t_sample *) w[3];
- t_sample * out2 =(t_sample *) w[4];
- t_int n =(t_int) w[5];
- //prepare, execute and output results
- memcpy(x->infft,in1,n*sizeof(t_sample));
fftwf_execute(x->plan);
! memcpy(out1,x->outreal,(n/2+1)*(sizeof(t_sample)));
! sigrfftw_invert(x->outimag,n/2);
! memcpy(out2,x->outimag,(n/2+1)*(sizeof(t_sample)));
! return (w+6);
}
--- 415,423 ----
{
t_sigrfftw * x =(t_sigrfftw *) w[1];
fftwf_execute(x->plan);
! sigrfftw_invert((t_sample*)w[2],(t_int)w[3]);
! return (w+4);
}
***************
*** 473,477 ****
{
int n = sp[0]->s_n, n2 = (n>>1);
! float *in1 = sp[0]->s_vec;
float *out1 = sp[1]->s_vec;
float *out2 = sp[2]->s_vec;
--- 425,429 ----
{
int n = sp[0]->s_n, n2 = (n>>1);
! float *in = sp[0]->s_vec;
float *out1 = sp[1]->s_vec;
float *out2 = sp[2]->s_vec;
***************
*** 484,499 ****
else
{
- // prepare the fft
- x->bins=n;
- x->infft = fftwf_malloc(sizeof(t_sample) * x->bins);
- x->outreal = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
- x->outimag = fftwf_malloc(sizeof(t_sample) * ((x->bins)/2+1));
x->dim.n=n;
x->dim.is=1;
x->dim.os=1;
! x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL, x->infft,
! x->outreal, x->outimag,
FFTW_MEASURE);
! dsp_add(sigrfftw_perform,5,x,in1,out1,out2,n);
}
--- 436,446 ----
else
{
x->dim.n=n;
x->dim.is=1;
x->dim.os=1;
! x->plan = fftwf_plan_guru_split_dft_r2c(1, &(x->dim), 0, NULL,
! in, out1, out2,
FFTW_MEASURE);
! dsp_add(sigrfftw_perform,3,x,out2+1,n2-1);
}
***************
*** 524,535 ****
fftwf_plan plan;
- t_int bins;
fftwf_iodim dim;
- t_sample * inreal;
- t_sample * inimag;
- t_sample * outfft;
} t_sigrifftw;
- //constructor
static void *sigrifftw_new(void)
{
--- 471,477 ----
***************
*** 541,550 ****
}
- //destructor
static void sigrifftw_free(t_sigrifftw *x)
{
- fftwf_free(x->inreal);
- fftwf_free(x->inimag);
- fftwf_free(x->outfft);
fftwf_destroy_plan(x->plan);
}
--- 483,488 ----
***************
*** 553,569 ****
{
t_sigrifftw * x =(t_sigrifftw *) w[1];
- t_sample * in1 =(t_sample *) w[2];
- t_sample * in2 =(t_sample *) w[3];
- t_sample * out1 =(t_sample *) w[4];
- t_int n =(t_int) w[5];
! //prepare, execute and output results
! memcpy(x->inreal,in1,(n/2+1)*sizeof(t_sample));
! memcpy(x->inimag,in2,(n/2+1)*sizeof(t_sample));
! sigrfftw_invert(x->inimag,n/2);
fftwf_execute(x->plan);
- memcpy(out1,x->outfft,n*(sizeof(t_sample)));
! return (w+6);
}
--- 491,499 ----
{
t_sigrifftw * x =(t_sigrifftw *) w[1];
! sigrfftw_invert((t_sample *)w[2],w[3]);
fftwf_execute(x->plan);
! return (w+4);
}
***************
*** 573,577 ****
float *in1 = sp[0]->s_vec;
float *in2 = sp[1]->s_vec;
! float *out1 = sp[2]->s_vec;
if (n < 4)
--- 503,507 ----
float *in1 = sp[0]->s_vec;
float *in2 = sp[1]->s_vec;
! float *out = sp[2]->s_vec;
if (n < 4)
***************
*** 584,598 ****
{
//prepare the fft
- x->bins=n;
- x->inreal = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
- x->inimag = fftwf_malloc(sizeof(t_sample) * (x->bins)/2+1);
- x->outfft = fftwf_malloc(sizeof(t_sample) * x->bins);
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, x->inreal,
! x->inimag, x->outfft,
FFTW_MEASURE);
! dsp_add(sigrifftw_perform,5,x,in1,in2,out1,n);
}
}
--- 514,524 ----
{
//prepare the fft
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_MEASURE);
! dsp_add(sigrifftw_perform,3,x,in2,n2);
}
}