From 66113ecc32634c47fd79a50854992063ad45b37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 1 Oct 2008 07:09:07 +0000 Subject: reverted my change with the ifdefs svn path=/trunk/externals/bsaylor/; revision=10320 --- partconv~.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'partconv~.c') diff --git a/partconv~.c b/partconv~.c index ccb4dff..373d580 100644 --- a/partconv~.c +++ b/partconv~.c @@ -31,13 +31,11 @@ #include #include -#ifdef HAVE_FFTW3_H -# include -#endif /* FFTW3 */ +#include #include "m_pd.h" #ifdef __VEC__ -# include +#include #endif #define MAXPARTS 256 // max number of partitions @@ -50,11 +48,9 @@ static t_class *partconv_class; struct sumbuffer { int index; -#ifdef HAVE_FFTW3_H fftwf_complex *fd; float *td; fftwf_plan plan; -#endif /* FFTW3 */ int readpos; struct sumbuffer *next, *prev; }; @@ -71,7 +67,6 @@ typedef struct _partconv { int ir_prepared; int pd_blocksize; -#ifdef HAVE_FFTW3_H // partitions of impulse response fftwf_plan irpart_plan; float *irpart_td[MAXPARTS]; @@ -83,8 +78,6 @@ typedef struct _partconv { int inbufpos; float *input_td; fftwf_complex *input_fd; -#endif /* FFTW3 */ - // circular array/list of buffers for accumulating results of convolution struct sumbuffer sumbufs[MAXPARTS+2]; @@ -134,7 +127,6 @@ static t_int *partconv_perform(t_int *w) t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); -#ifdef HAVE_FFTW3_H int i; int j; int k; // bin @@ -148,7 +140,7 @@ static t_int *partconv_perform(t_int *w) v4sf *cursumbuf_fd; v4sf *input_fd; v4sf *irpart_fd; -#elif defined HAVE_FFTW3_H +#else fftwf_complex *cursumbuf_fd; fftwf_complex *input_fd; fftwf_complex *irpart_fd; @@ -173,7 +165,9 @@ static t_int *partconv_perform(t_int *w) x->curpart = 0; memcpy(x->input_td, x->inbuf, x->partsize * sizeof(float)); // copy 'gathering' input buffer into 'transform' buffer memset(&(x->input_td[x->partsize]), 0, (x->paddedsize - x->partsize) * sizeof(float)); // pad + fftwf_execute(x->input_plan); // transform the input + // everything has been read out of prev sumbuf, so clear it memset(x->sumbuf->prev->td, 0, x->paddedsize * sizeof(float)); @@ -190,7 +184,7 @@ static t_int *partconv_perform(t_int *w) for (p = x->curpart; p < endpart; p++) { // multiply the input block by the partition, accumulating the result in the appropriate sumbuf #ifdef USE_SSE -# include "sse-conv.inc.c" +#include "sse-conv.inc.c" #else cursumbuf_fd = x->sumbufs[(x->sumbuf->index + p) % x->nsumbufs].fd; input_fd = x->input_fd; @@ -232,10 +226,6 @@ static t_int *partconv_perform(t_int *w) x->sumbuf->prev->readpos += n; x->curcall++; -#else /* !FFTW3 */ - while(n-->0) - *out++=*in++; -#endif return (w+5); } @@ -244,8 +234,8 @@ static t_int *partconv_perform(t_int *w) static void partconv_free(t_partconv *x) { -#ifdef HAVE_FFTW3_H int i; + fftwf_free(x->inbuf); for (i = 0; i < x->nparts; i++) fftwf_free(x->irpart_td[i]); @@ -255,7 +245,6 @@ static void partconv_free(t_partconv *x) fftwf_free(x->sumbufs[i].fd); fftwf_destroy_plan(x->sumbufs[i].plan); } -#endif /* FFTW3 */ } static void partconv_set(t_partconv *x, t_symbol *s) @@ -278,7 +267,7 @@ static void partconv_set(t_partconv *x, t_symbol *s) pd_error(x, "%s: bad template", x->arrayname->s_name); return; } -#ifdef HAVE_FFTW3_H + // if the IR has already been prepared, free everything first if (x->ir_prepared == 1) { partconv_free(x); @@ -339,7 +328,6 @@ static void partconv_set(t_partconv *x, t_symbol *s) post("partconv~: using %s in %d partitions with FFT-size %d", x->arrayname->s_name, x->nparts, x->fftsize); x->ir_prepared = 1; -#endif /* FFTW3 */ } static void partconv_dsp(t_partconv *x, t_signal **sp) @@ -359,7 +347,7 @@ static void *partconv_new(t_symbol *s, int argc, t_atom *argv) outlet_new(&x->x_obj, gensym("signal")); if (argc != 2) { - // post("argc = %d", argc); + post("argc = %d", argc); error("partconv~: usage: [partconv~ ]\n\t- partition size must be a power of 2 >= blocksize"); return NULL; } @@ -385,11 +373,6 @@ static void *partconv_new(t_symbol *s, int argc, t_atom *argv) x->ir_prepared = 0; x->pd_blocksize = sys_getblksize(); -#ifndef HAVE_FFTW3_H - pd_error(x, "partconv~: compiled without FFTW3 support! this is a dummy!"); -#endif - - return (x); } -- cgit v1.2.1