[96fb8ad] | 1 | /* |
---|
[a47cd35] | 2 | Copyright (C) 2003 Paul Brossier |
---|
| 3 | |
---|
| 4 | This program is free software; you can redistribute it and/or modify |
---|
| 5 | it under the terms of the GNU General Public License as published by |
---|
| 6 | the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | (at your option) any later version. |
---|
| 8 | |
---|
| 9 | This program is distributed in the hope that it will be useful, |
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | GNU General Public License for more details. |
---|
| 13 | |
---|
| 14 | You should have received a copy of the GNU General Public License |
---|
| 15 | along with this program; if not, write to the Free Software |
---|
| 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 17 | |
---|
[96fb8ad] | 18 | */ |
---|
| 19 | |
---|
[2afdb0f] | 20 | /** \file |
---|
| 21 | |
---|
| 22 | Fast Fourier Transform object |
---|
| 23 | |
---|
| 24 | */ |
---|
[96fb8ad] | 25 | |
---|
| 26 | #ifndef FFT_H_ |
---|
| 27 | #define FFT_H_ |
---|
[66834b6] | 28 | |
---|
[96fb8ad] | 29 | #ifdef __cplusplus |
---|
| 30 | extern "C" { |
---|
| 31 | #endif |
---|
| 32 | |
---|
[2afdb0f] | 33 | /** FFT object |
---|
| 34 | |
---|
| 35 | This object computes forward and backward FFTs, using the complex type to |
---|
| 36 | store the results. The phase vocoder or aubio_mfft_t objects should be |
---|
| 37 | preferred to using directly aubio_fft_t. The FFT are computed using FFTW3 |
---|
| 38 | (although support for another library could be added). |
---|
| 39 | |
---|
| 40 | */ |
---|
[96fb8ad] | 41 | typedef struct _aubio_fft_t aubio_fft_t; |
---|
| 42 | |
---|
[2afdb0f] | 43 | /** create new FFT computation object |
---|
| 44 | |
---|
| 45 | \param size length of the FFT |
---|
[aadd27a] | 46 | \param channels number of channels |
---|
[2afdb0f] | 47 | |
---|
| 48 | */ |
---|
[aadd27a] | 49 | aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels); |
---|
[2afdb0f] | 50 | /** delete FFT object |
---|
| 51 | |
---|
| 52 | \param s fft object as returned by new_aubio_fft |
---|
| 53 | |
---|
| 54 | */ |
---|
[227564e] | 55 | void del_aubio_fft(aubio_fft_t * s); |
---|
[aadd27a] | 56 | |
---|
[2afdb0f] | 57 | /** compute forward FFT |
---|
| 58 | |
---|
| 59 | \param s fft object as returned by new_aubio_fft |
---|
[aadd27a] | 60 | \param input input signal |
---|
[2afdb0f] | 61 | \param spectrum output spectrum |
---|
| 62 | |
---|
| 63 | */ |
---|
[aadd27a] | 64 | void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum); |
---|
[2afdb0f] | 65 | /** compute backward (inverse) FFT |
---|
| 66 | |
---|
| 67 | \param s fft object as returned by new_aubio_fft |
---|
| 68 | \param spectrum input spectrum |
---|
[aadd27a] | 69 | \param output output signal |
---|
[2afdb0f] | 70 | |
---|
| 71 | */ |
---|
[aadd27a] | 72 | void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output); |
---|
[2afdb0f] | 73 | |
---|
[aadd27a] | 74 | /** compute forward FFT |
---|
| 75 | |
---|
| 76 | \param s fft object as returned by new_aubio_fft |
---|
| 77 | \param input real input signal |
---|
| 78 | \param compspec complex output fft real/imag |
---|
[2afdb0f] | 79 | |
---|
| 80 | */ |
---|
[aadd27a] | 81 | void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec); |
---|
| 82 | /** compute backward (inverse) FFT from real/imag |
---|
| 83 | |
---|
| 84 | \param s fft object as returned by new_aubio_fft |
---|
| 85 | \param compspec real/imag input fft array |
---|
| 86 | \param output real output array |
---|
[2afdb0f] | 87 | |
---|
| 88 | */ |
---|
[aadd27a] | 89 | void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output); |
---|
[96fb8ad] | 90 | |
---|
[aadd27a] | 91 | /** convert real/imag spectrum to norm/phas spectrum |
---|
[f88a326] | 92 | |
---|
[aadd27a] | 93 | \param compspec real/imag input fft array |
---|
| 94 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 95 | |
---|
| 96 | */ |
---|
[aadd27a] | 97 | void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum); |
---|
| 98 | /** convert real/imag spectrum to norm/phas spectrum |
---|
[2afdb0f] | 99 | |
---|
[aadd27a] | 100 | \param compspec real/imag input fft array |
---|
| 101 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 102 | |
---|
| 103 | */ |
---|
[aadd27a] | 104 | void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec); |
---|
| 105 | |
---|
| 106 | /** compute phas spectrum from real/imag parts |
---|
[2afdb0f] | 107 | |
---|
[aadd27a] | 108 | \param compspec real/imag input fft array |
---|
| 109 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 110 | |
---|
| 111 | */ |
---|
[aadd27a] | 112 | void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum); |
---|
| 113 | /** compute imaginary part from the norm/phas cvec |
---|
[2afdb0f] | 114 | |
---|
[aadd27a] | 115 | \param spectrum norm/phas input array |
---|
| 116 | \param compspec real/imag output fft array |
---|
[2afdb0f] | 117 | |
---|
| 118 | */ |
---|
[aadd27a] | 119 | void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec); |
---|
[2afdb0f] | 120 | |
---|
[aadd27a] | 121 | /** compute norm component from real/imag parts |
---|
| 122 | |
---|
| 123 | \param compspec real/imag input fft array |
---|
| 124 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 125 | |
---|
| 126 | */ |
---|
[aadd27a] | 127 | void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum); |
---|
| 128 | /** compute real part from norm/phas components |
---|
| 129 | |
---|
| 130 | \param spectrum norm/phas input array |
---|
| 131 | \param compspec real/imag output fft array |
---|
[f88a326] | 132 | |
---|
[aadd27a] | 133 | */ |
---|
| 134 | void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec); |
---|
[f88a326] | 135 | |
---|
[96fb8ad] | 136 | #ifdef __cplusplus |
---|
| 137 | } |
---|
| 138 | #endif |
---|
| 139 | |
---|
[aadd27a] | 140 | #endif // FFT_H_ |
---|