From a47cd35a0f2c78a48369f69a59f24fcc7fd81e4b Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 3 Nov 2007 14:52:34 +0100 Subject: [PATCH] fft.{c,h}: remove tabs --- src/fft.c | 167 ++++++++++++++++++++++++++---------------------------- src/fft.h | 32 +++++------ 2 files changed, 96 insertions(+), 103 deletions(-) diff --git a/src/fft.c b/src/fft.c index 53566989..5cbc4780 100644 --- a/src/fft.c +++ b/src/fft.c @@ -23,14 +23,14 @@ #include "fft.h" #if FFTW3F_SUPPORT -#define fftw_malloc fftwf_malloc -#define fftw_free fftwf_free -#define fftw_execute fftwf_execute -#define fftw_plan_dft_r2c_1d fftwf_plan_dft_r2c_1d -#define fftw_plan_dft_c2r_1d fftwf_plan_dft_c2r_1d -#define fftw_plan_r2r_1d fftwf_plan_r2r_1d -#define fftw_plan fftwf_plan -#define fftw_destroy_plan fftwf_destroy_plan +#define fftw_malloc fftwf_malloc +#define fftw_free fftwf_free +#define fftw_execute fftwf_execute +#define fftw_plan_dft_r2c_1d fftwf_plan_dft_r2c_1d +#define fftw_plan_dft_c2r_1d fftwf_plan_dft_c2r_1d +#define fftw_plan_r2r_1d fftwf_plan_r2r_1d +#define fftw_plan fftwf_plan +#define fftw_destroy_plan fftwf_destroy_plan #endif #if FFTW3F_SUPPORT @@ -40,77 +40,72 @@ #endif struct _aubio_fft_t { - uint_t fft_size; - uint_t channels; - real_t *in, *out; - fft_data_t *specdata; - fftw_plan pfw, pbw; + uint_t fft_size; + uint_t channels; + real_t *in, *out; + fft_data_t *specdata; + fftw_plan pfw, pbw; }; static void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size); aubio_fft_t * new_aubio_fft(uint_t size) { - aubio_fft_t * s = AUBIO_NEW(aubio_fft_t); - /* allocate memory */ - s->in = AUBIO_ARRAY(real_t,size); - s->out = AUBIO_ARRAY(real_t,size); - /* create plans */ + aubio_fft_t * s = AUBIO_NEW(aubio_fft_t); + /* allocate memory */ + s->in = AUBIO_ARRAY(real_t,size); + s->out = AUBIO_ARRAY(real_t,size); + /* create plans */ #ifdef HAVE_COMPLEX_H s->fft_size = size/2+1; - s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size); - s->pfw = fftw_plan_dft_r2c_1d(size, s->in, s->specdata, FFTW_ESTIMATE); - s->pbw = fftw_plan_dft_c2r_1d(size, s->specdata, s->out, FFTW_ESTIMATE); + s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size); + s->pfw = fftw_plan_dft_r2c_1d(size, s->in, s->specdata, FFTW_ESTIMATE); + s->pbw = fftw_plan_dft_c2r_1d(size, s->specdata, s->out, FFTW_ESTIMATE); #else s->fft_size = size; - s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size); - s->pfw = fftw_plan_r2r_1d(size, s->in, s->specdata, FFTW_R2HC, FFTW_ESTIMATE); - s->pbw = fftw_plan_r2r_1d(size, s->specdata, s->out, FFTW_HC2R, FFTW_ESTIMATE); + s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size); + s->pfw = fftw_plan_r2r_1d(size, s->in, s->specdata, FFTW_R2HC, FFTW_ESTIMATE); + s->pbw = fftw_plan_r2r_1d(size, s->specdata, s->out, FFTW_HC2R, FFTW_ESTIMATE); #endif - return s; + return s; } void del_aubio_fft(aubio_fft_t * s) { - /* destroy data */ - fftw_destroy_plan(s->pfw); - fftw_destroy_plan(s->pbw); - fftw_free(s->specdata); - AUBIO_FREE(s->out); - AUBIO_FREE(s->in ); - AUBIO_FREE(s); + /* destroy data */ + fftw_destroy_plan(s->pfw); + fftw_destroy_plan(s->pbw); + fftw_free(s->specdata); + AUBIO_FREE(s->out); + AUBIO_FREE(s->in ); + AUBIO_FREE(s); } void aubio_fft_do(const aubio_fft_t * s, - const smpl_t * data, fft_data_t * spectrum, - const uint_t size) { - uint_t i; - for (i=0;iin[i] = data[i]; - fftw_execute(s->pfw); - for (i=0; i < s->fft_size; i++) spectrum[i] = s->specdata[i]; + const smpl_t * data, fft_data_t * spectrum, const uint_t size) { + uint_t i; + for (i=0;iin[i] = data[i]; + fftw_execute(s->pfw); + for (i=0; i < s->fft_size; i++) spectrum[i] = s->specdata[i]; } void aubio_fft_rdo(const aubio_fft_t * s, - const fft_data_t * spectrum, - smpl_t * data, - const uint_t size) { - uint_t i; - const smpl_t renorm = 1./(smpl_t)size; - for (i=0; i < s->fft_size; i++) s->specdata[i] = spectrum[i]; - fftw_execute(s->pbw); - for (i=0;iout[i]*renorm; + const fft_data_t * spectrum, smpl_t * data, const uint_t size) { + uint_t i; + const smpl_t renorm = 1./(smpl_t)size; + for (i=0; i < s->fft_size; i++) s->specdata[i] = spectrum[i]; + fftw_execute(s->pbw); + for (i=0;iout[i]*renorm; } #ifdef HAVE_COMPLEX_H void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size) { - uint_t i; - for (i=0;iwinsize = winsize; - fft->channels = channels; - fft->fft = new_aubio_fft(winsize); - fft->spec = AUBIO_ARRAY(fft_data_t*,channels); - for (i=0; i < channels; i++) - fft->spec[i] = AUBIO_ARRAY(fft_data_t,winsize); - return fft; + uint_t i; + aubio_mfft_t * fft = AUBIO_NEW(aubio_mfft_t); + fft->winsize = winsize; + fft->channels = channels; + fft->fft = new_aubio_fft(winsize); + fft->spec = AUBIO_ARRAY(fft_data_t*,channels); + for (i=0; i < channels; i++) + fft->spec[i] = AUBIO_ARRAY(fft_data_t,winsize); + return fft; } /* execute stft */ void aubio_mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain){ - uint_t i=0; - /* execute stft */ - for (i=0; i < fft->channels; i++) { - aubio_fft_do (fft->fft,in->data[i],fft->spec[i],fft->winsize); - /* put norm and phase into fftgrain */ - aubio_fft_getnorm(fftgrain->norm[i], fft->spec[i], fft->winsize); - aubio_fft_getphas(fftgrain->phas[i], fft->spec[i], fft->winsize); - } + uint_t i=0; + /* execute stft */ + for (i=0; i < fft->channels; i++) { + aubio_fft_do (fft->fft,in->data[i],fft->spec[i],fft->winsize); + /* put norm and phase into fftgrain */ + aubio_fft_getnorm(fftgrain->norm[i], fft->spec[i], fft->winsize); + aubio_fft_getphas(fftgrain->phas[i], fft->spec[i], fft->winsize); + } } /* execute inverse fourier transform */ void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out){ - uint_t i=0; - for (i=0; i < fft->channels; i++) { - aubio_fft_getspectrum(fft->spec[i],fftgrain->norm[i],fftgrain->phas[i],fft->winsize); - aubio_fft_rdo(fft->fft,fft->spec[i],out->data[i],fft->winsize); - } + uint_t i=0; + for (i=0; i < fft->channels; i++) { + aubio_fft_getspectrum(fft->spec[i],fftgrain->norm[i],fftgrain->phas[i],fft->winsize); + aubio_fft_rdo(fft->fft,fft->spec[i],out->data[i],fft->winsize); + } } void del_aubio_mfft(aubio_mfft_t * fft) { - uint_t i; - for (i=0; i < fft->channels; i++) - AUBIO_FREE(fft->spec[i]); - AUBIO_FREE(fft->spec); - del_aubio_fft(fft->fft); - AUBIO_FREE(fft); + uint_t i; + for (i=0; i < fft->channels; i++) + AUBIO_FREE(fft->spec[i]); + AUBIO_FREE(fft->spec); + del_aubio_fft(fft->fft); + AUBIO_FREE(fft); } diff --git a/src/fft.h b/src/fft.h index a2abeca2..72187eb3 100644 --- a/src/fft.h +++ b/src/fft.h @@ -1,20 +1,20 @@ /* - Copyright (C) 2003 Paul Brossier - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - + Copyright (C) 2003 Paul Brossier + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /** \file -- 2.26.2