1 | /* |
---|
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 | |
---|
18 | */ |
---|
19 | |
---|
20 | /** \file |
---|
21 | |
---|
22 | Fast Fourier Transform object |
---|
23 | |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef FFT_H_ |
---|
27 | #define FFT_H_ |
---|
28 | |
---|
29 | /* note that <complex.h> is not included here but only in aubio_priv.h, so that |
---|
30 | * c++ projects can still use their own complex definition. */ |
---|
31 | #include <fftw3.h> |
---|
32 | |
---|
33 | #ifdef HAVE_COMPLEX_H |
---|
34 | #if HAVE_FFTW3F |
---|
35 | /** fft data type with complex.h and fftw3f */ |
---|
36 | #define FFTW_TYPE fftwf_complex |
---|
37 | #else |
---|
38 | /** fft data type with complex.h and fftw3 */ |
---|
39 | #define FFTW_TYPE fftw_complex |
---|
40 | #endif |
---|
41 | #else |
---|
42 | #if HAVE_FFTW3F |
---|
43 | /** fft data type without complex.h and with fftw3f */ |
---|
44 | #define FFTW_TYPE float |
---|
45 | #else |
---|
46 | /** fft data type without complex.h and with fftw */ |
---|
47 | #define FFTW_TYPE double |
---|
48 | #endif |
---|
49 | #endif |
---|
50 | |
---|
51 | #ifdef __cplusplus |
---|
52 | extern "C" { |
---|
53 | #endif |
---|
54 | |
---|
55 | /** fft data type */ |
---|
56 | typedef FFTW_TYPE fft_data_t; |
---|
57 | |
---|
58 | /** FFT object |
---|
59 | |
---|
60 | This object computes forward and backward FFTs, using the complex type to |
---|
61 | store the results. The phase vocoder or aubio_mfft_t objects should be |
---|
62 | preferred to using directly aubio_fft_t. The FFT are computed using FFTW3 |
---|
63 | (although support for another library could be added). |
---|
64 | |
---|
65 | */ |
---|
66 | typedef struct _aubio_fft_t aubio_fft_t; |
---|
67 | |
---|
68 | /** create new FFT computation object |
---|
69 | |
---|
70 | \param size length of the FFT |
---|
71 | \param channels number of channels |
---|
72 | |
---|
73 | */ |
---|
74 | aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels); |
---|
75 | /** delete FFT object |
---|
76 | |
---|
77 | \param s fft object as returned by new_aubio_fft |
---|
78 | |
---|
79 | */ |
---|
80 | void del_aubio_fft(aubio_fft_t * s); |
---|
81 | |
---|
82 | /** compute forward FFT |
---|
83 | |
---|
84 | \param s fft object as returned by new_aubio_fft |
---|
85 | \param input input signal |
---|
86 | \param spectrum output spectrum |
---|
87 | |
---|
88 | */ |
---|
89 | void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum); |
---|
90 | /** compute backward (inverse) FFT |
---|
91 | |
---|
92 | \param s fft object as returned by new_aubio_fft |
---|
93 | \param spectrum input spectrum |
---|
94 | \param output output signal |
---|
95 | |
---|
96 | */ |
---|
97 | void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output); |
---|
98 | |
---|
99 | /** compute forward FFT |
---|
100 | |
---|
101 | \param s fft object as returned by new_aubio_fft |
---|
102 | \param input real input signal |
---|
103 | \param compspec complex output fft real/imag |
---|
104 | |
---|
105 | */ |
---|
106 | void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec); |
---|
107 | /** compute backward (inverse) FFT from real/imag |
---|
108 | |
---|
109 | \param s fft object as returned by new_aubio_fft |
---|
110 | \param compspec real/imag input fft array |
---|
111 | \param output real output array |
---|
112 | |
---|
113 | */ |
---|
114 | void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output); |
---|
115 | |
---|
116 | /** convert real/imag spectrum to norm/phas spectrum |
---|
117 | |
---|
118 | \param compspec real/imag input fft array |
---|
119 | \param spectrum cvec norm/phas output array |
---|
120 | |
---|
121 | */ |
---|
122 | void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum); |
---|
123 | /** convert real/imag spectrum to norm/phas spectrum |
---|
124 | |
---|
125 | \param compspec real/imag input fft array |
---|
126 | \param spectrum cvec norm/phas output array |
---|
127 | |
---|
128 | */ |
---|
129 | void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec); |
---|
130 | |
---|
131 | /** compute phas spectrum from real/imag parts |
---|
132 | |
---|
133 | \param compspec real/imag input fft array |
---|
134 | \param spectrum cvec norm/phas output array |
---|
135 | |
---|
136 | */ |
---|
137 | void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum); |
---|
138 | /** compute imaginary part from the norm/phas cvec |
---|
139 | |
---|
140 | \param spectrum norm/phas input array |
---|
141 | \param compspec real/imag output fft array |
---|
142 | |
---|
143 | */ |
---|
144 | void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec); |
---|
145 | |
---|
146 | /** compute norm component from real/imag parts |
---|
147 | |
---|
148 | \param compspec real/imag input fft array |
---|
149 | \param spectrum cvec norm/phas output array |
---|
150 | |
---|
151 | */ |
---|
152 | void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum); |
---|
153 | /** compute real part from norm/phas components |
---|
154 | |
---|
155 | \param spectrum norm/phas input array |
---|
156 | \param compspec real/imag output fft array |
---|
157 | |
---|
158 | */ |
---|
159 | void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec); |
---|
160 | |
---|
161 | #ifdef __cplusplus |
---|
162 | } |
---|
163 | #endif |
---|
164 | |
---|
165 | #endif // FFT_H_ |
---|