andrew@0: /* andrew@0: Copyright (C) 2003 Paul Brossier andrew@0: andrew@0: This program is free software; you can redistribute it and/or modify andrew@0: it under the terms of the GNU General Public License as published by andrew@0: the Free Software Foundation; either version 2 of the License, or andrew@0: (at your option) any later version. andrew@0: andrew@0: This program is distributed in the hope that it will be useful, andrew@0: but WITHOUT ANY WARRANTY; without even the implied warranty of andrew@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrew@0: GNU General Public License for more details. andrew@0: andrew@0: You should have received a copy of the GNU General Public License andrew@0: along with this program; if not, write to the Free Software andrew@0: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. andrew@0: andrew@0: */ andrew@0: andrew@0: /** \file andrew@0: andrew@0: Fast Fourier Transform object andrew@0: andrew@0: */ andrew@0: andrew@0: #ifndef FFT_H_ andrew@0: #define FFT_H_ andrew@0: andrew@0: /* note that is not included here but only in aubio_priv.h, so that andrew@0: * c++ projects can still use their own complex definition. */ andrew@0: #include andrew@0: andrew@0: #ifdef HAVE_COMPLEX_H andrew@0: #if FFTW3F_SUPPORT andrew@0: #define FFTW_TYPE fftwf_complex andrew@0: #else andrew@0: #define FFTW_TYPE fftw_complex andrew@0: #endif andrew@0: #else andrew@0: #if FFTW3F_SUPPORT andrew@0: /** fft data type */ andrew@0: #define FFTW_TYPE float andrew@0: #else andrew@0: /** fft data type */ andrew@0: #define FFTW_TYPE double andrew@0: #endif andrew@0: #endif andrew@0: andrew@0: #ifdef __cplusplus andrew@0: extern "C" { andrew@0: #endif andrew@0: andrew@0: /** fft data type */ andrew@0: typedef FFTW_TYPE fft_data_t; andrew@0: andrew@0: /** FFT object andrew@0: andrew@0: This object computes forward and backward FFTs, using the complex type to andrew@0: store the results. The phase vocoder or aubio_mfft_t objects should be andrew@0: preferred to using directly aubio_fft_t. The FFT are computed using FFTW3 andrew@0: (although support for another library could be added). andrew@0: andrew@0: */ andrew@0: typedef struct _aubio_fft_t aubio_fft_t; andrew@0: andrew@0: /** create new FFT computation object andrew@0: andrew@0: \param size length of the FFT andrew@0: andrew@0: */ andrew@0: aubio_fft_t * new_aubio_fft(ba_uint_t size); andrew@0: /** delete FFT object andrew@0: andrew@0: \param s fft object as returned by new_aubio_fft andrew@0: andrew@0: */ andrew@0: void del_aubio_fft(aubio_fft_t * s); andrew@0: /** compute forward FFT andrew@0: andrew@0: \param s fft object as returned by new_aubio_fft andrew@0: \param data input signal andrew@0: \param spectrum output spectrum andrew@0: \param size length of the input vector andrew@0: andrew@0: */ andrew@0: void aubio_fft_do (const aubio_fft_t *s, const smpl_t * data, andrew@0: fft_data_t * spectrum, const ba_uint_t size); andrew@0: /** compute backward (inverse) FFT andrew@0: andrew@0: \param s fft object as returned by new_aubio_fft andrew@0: \param spectrum input spectrum andrew@0: \param data output signal andrew@0: \param size length of the input vector andrew@0: andrew@0: */ andrew@0: void aubio_fft_rdo(const aubio_fft_t *s, const fft_data_t * spectrum, andrew@0: smpl_t * data, const ba_uint_t size); andrew@0: /** compute norm vector from input spectrum andrew@0: andrew@0: \param norm magnitude vector output andrew@0: \param spectrum spectral data input andrew@0: \param size size of the vectors andrew@0: andrew@0: */ andrew@0: void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, ba_uint_t size); andrew@0: /** compute phase vector from input spectrum andrew@0: andrew@0: \param phase phase vector output andrew@0: \param spectrum spectral data input andrew@0: \param size size of the vectors andrew@0: andrew@0: */ andrew@0: void aubio_fft_getphas(smpl_t * phase, fft_data_t * spectrum, ba_uint_t size); andrew@0: andrew@0: /** FFT object (using cvec) andrew@0: andrew@0: This object works similarly as aubio_fft_t, except the spectral data is andrew@0: stored in a cvec_t as two vectors, magnitude and phase. andrew@0: andrew@0: */ andrew@0: typedef struct _aubio_mfft_t aubio_mfft_t; andrew@0: andrew@0: /** create new FFT computation object andrew@0: andrew@0: \param winsize length of the FFT andrew@0: \param channels number of channels andrew@0: andrew@0: */ andrew@0: aubio_mfft_t * new_aubio_mfft(ba_uint_t winsize, ba_uint_t channels); andrew@0: /** compute forward FFT andrew@0: andrew@0: \param fft fft object as returned by new_aubio_mfft andrew@0: \param in input signal andrew@0: \param fftgrain output spectrum andrew@0: andrew@0: */ andrew@0: void aubio_mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain); andrew@0: /** compute backward (inverse) FFT andrew@0: andrew@0: \param fft fft object as returned by new_aubio_mfft andrew@0: \param fftgrain input spectrum (cvec) andrew@0: \param out output signal andrew@0: andrew@0: */ andrew@0: void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out); andrew@0: /** delete FFT object andrew@0: andrew@0: \param fft fft object as returned by new_aubio_mfft andrew@0: andrew@0: */ andrew@0: void del_aubio_mfft(aubio_mfft_t * fft); andrew@0: andrew@0: andrew@0: #ifdef __cplusplus andrew@0: } andrew@0: #endif andrew@0: andrew@0: #endif