[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 | |
---|
| 25 | */ |
---|
[96fb8ad] | 26 | |
---|
| 27 | #ifndef FFT_H_ |
---|
| 28 | #define FFT_H_ |
---|
[66834b6] | 29 | |
---|
[96fb8ad] | 30 | #ifdef __cplusplus |
---|
| 31 | extern "C" { |
---|
| 32 | #endif |
---|
| 33 | |
---|
[2afdb0f] | 34 | /** FFT object |
---|
| 35 | |
---|
| 36 | This object computes forward and backward FFTs, using the complex type to |
---|
| 37 | store the results. The phase vocoder or aubio_mfft_t objects should be |
---|
| 38 | preferred to using directly aubio_fft_t. The FFT are computed using FFTW3 |
---|
| 39 | (although support for another library could be added). |
---|
| 40 | |
---|
| 41 | */ |
---|
[96fb8ad] | 42 | typedef struct _aubio_fft_t aubio_fft_t; |
---|
| 43 | |
---|
[2afdb0f] | 44 | /** create new FFT computation object |
---|
| 45 | |
---|
| 46 | \param size length of the FFT |
---|
[aadd27a] | 47 | \param channels number of channels |
---|
[2afdb0f] | 48 | |
---|
| 49 | */ |
---|
[aadd27a] | 50 | aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels); |
---|
[2afdb0f] | 51 | /** delete FFT object |
---|
| 52 | |
---|
| 53 | \param s fft object as returned by new_aubio_fft |
---|
| 54 | |
---|
| 55 | */ |
---|
[227564e] | 56 | void del_aubio_fft(aubio_fft_t * s); |
---|
[aadd27a] | 57 | |
---|
[2afdb0f] | 58 | /** compute forward FFT |
---|
| 59 | |
---|
| 60 | \param s fft object as returned by new_aubio_fft |
---|
[aadd27a] | 61 | \param input input signal |
---|
[2afdb0f] | 62 | \param spectrum output spectrum |
---|
| 63 | |
---|
| 64 | */ |
---|
[aadd27a] | 65 | void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum); |
---|
[2afdb0f] | 66 | /** compute backward (inverse) FFT |
---|
| 67 | |
---|
| 68 | \param s fft object as returned by new_aubio_fft |
---|
| 69 | \param spectrum input spectrum |
---|
[aadd27a] | 70 | \param output output signal |
---|
[2afdb0f] | 71 | |
---|
| 72 | */ |
---|
[aadd27a] | 73 | void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output); |
---|
[2afdb0f] | 74 | |
---|
[aadd27a] | 75 | /** compute forward FFT |
---|
| 76 | |
---|
| 77 | \param s fft object as returned by new_aubio_fft |
---|
| 78 | \param input real input signal |
---|
| 79 | \param compspec complex output fft real/imag |
---|
[2afdb0f] | 80 | |
---|
| 81 | */ |
---|
[aadd27a] | 82 | void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec); |
---|
| 83 | /** compute backward (inverse) FFT from real/imag |
---|
| 84 | |
---|
| 85 | \param s fft object as returned by new_aubio_fft |
---|
| 86 | \param compspec real/imag input fft array |
---|
| 87 | \param output real output array |
---|
[2afdb0f] | 88 | |
---|
| 89 | */ |
---|
[aadd27a] | 90 | void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output); |
---|
[96fb8ad] | 91 | |
---|
[aadd27a] | 92 | /** convert real/imag spectrum to norm/phas spectrum |
---|
[f88a326] | 93 | |
---|
[aadd27a] | 94 | \param compspec real/imag input fft array |
---|
| 95 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 96 | |
---|
| 97 | */ |
---|
[aadd27a] | 98 | void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum); |
---|
| 99 | /** convert real/imag spectrum to norm/phas spectrum |
---|
[2afdb0f] | 100 | |
---|
[aadd27a] | 101 | \param compspec real/imag input fft array |
---|
| 102 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 103 | |
---|
| 104 | */ |
---|
[aadd27a] | 105 | void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec); |
---|
| 106 | |
---|
| 107 | /** compute phas spectrum from real/imag parts |
---|
[2afdb0f] | 108 | |
---|
[aadd27a] | 109 | \param compspec real/imag input fft array |
---|
| 110 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 111 | |
---|
| 112 | */ |
---|
[aadd27a] | 113 | void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum); |
---|
| 114 | /** compute imaginary part from the norm/phas cvec |
---|
[2afdb0f] | 115 | |
---|
[aadd27a] | 116 | \param spectrum norm/phas input array |
---|
| 117 | \param compspec real/imag output fft array |
---|
[2afdb0f] | 118 | |
---|
| 119 | */ |
---|
[aadd27a] | 120 | void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec); |
---|
[2afdb0f] | 121 | |
---|
[aadd27a] | 122 | /** compute norm component from real/imag parts |
---|
| 123 | |
---|
| 124 | \param compspec real/imag input fft array |
---|
| 125 | \param spectrum cvec norm/phas output array |
---|
[2afdb0f] | 126 | |
---|
| 127 | */ |
---|
[aadd27a] | 128 | void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum); |
---|
| 129 | /** compute real part from norm/phas components |
---|
| 130 | |
---|
| 131 | \param spectrum norm/phas input array |
---|
| 132 | \param compspec real/imag output fft array |
---|
[f88a326] | 133 | |
---|
[aadd27a] | 134 | */ |
---|
| 135 | void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec); |
---|
[f88a326] | 136 | |
---|
[96fb8ad] | 137 | #ifdef __cplusplus |
---|
| 138 | } |
---|
| 139 | #endif |
---|
| 140 | |
---|
[aadd27a] | 141 | #endif // FFT_H_ |
---|