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