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