andrew@0
|
1 /*
|
andrew@0
|
2 Copyright (C) 2003 Paul Brossier
|
andrew@0
|
3
|
andrew@0
|
4 This program is free software; you can redistribute it and/or modify
|
andrew@0
|
5 it under the terms of the GNU General Public License as published by
|
andrew@0
|
6 the Free Software Foundation; either version 2 of the License, or
|
andrew@0
|
7 (at your option) any later version.
|
andrew@0
|
8
|
andrew@0
|
9 This program is distributed in the hope that it will be useful,
|
andrew@0
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
andrew@0
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
andrew@0
|
12 GNU General Public License for more details.
|
andrew@0
|
13
|
andrew@0
|
14 You should have received a copy of the GNU General Public License
|
andrew@0
|
15 along with this program; if not, write to the Free Software
|
andrew@0
|
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
andrew@0
|
17
|
andrew@0
|
18 */
|
andrew@0
|
19
|
andrew@0
|
20 /** \file
|
andrew@0
|
21
|
andrew@0
|
22 Fast Fourier Transform object
|
andrew@0
|
23
|
andrew@0
|
24 */
|
andrew@0
|
25
|
andrew@0
|
26 #ifndef FFT_H_
|
andrew@0
|
27 #define FFT_H_
|
andrew@0
|
28
|
andrew@0
|
29 /* note that <complex.h> is not included here but only in aubio_priv.h, so that
|
andrew@0
|
30 * c++ projects can still use their own complex definition. */
|
andrew@0
|
31 #include <fftw3.h>
|
andrew@0
|
32
|
andrew@0
|
33 #ifdef HAVE_COMPLEX_H
|
andrew@0
|
34 #if FFTW3F_SUPPORT
|
andrew@0
|
35 #define FFTW_TYPE fftwf_complex
|
andrew@0
|
36 #else
|
andrew@0
|
37 #define FFTW_TYPE fftw_complex
|
andrew@0
|
38 #endif
|
andrew@0
|
39 #else
|
andrew@0
|
40 #if FFTW3F_SUPPORT
|
andrew@0
|
41 /** fft data type */
|
andrew@0
|
42 #define FFTW_TYPE float
|
andrew@0
|
43 #else
|
andrew@0
|
44 /** fft data type */
|
andrew@0
|
45 #define FFTW_TYPE double
|
andrew@0
|
46 #endif
|
andrew@0
|
47 #endif
|
andrew@0
|
48
|
andrew@0
|
49 #ifdef __cplusplus
|
andrew@0
|
50 extern "C" {
|
andrew@0
|
51 #endif
|
andrew@0
|
52
|
andrew@0
|
53 /** fft data type */
|
andrew@0
|
54 typedef FFTW_TYPE fft_data_t;
|
andrew@0
|
55
|
andrew@0
|
56 /** FFT object
|
andrew@0
|
57
|
andrew@0
|
58 This object computes forward and backward FFTs, using the complex type to
|
andrew@0
|
59 store the results. The phase vocoder or aubio_mfft_t objects should be
|
andrew@0
|
60 preferred to using directly aubio_fft_t. The FFT are computed using FFTW3
|
andrew@0
|
61 (although support for another library could be added).
|
andrew@0
|
62
|
andrew@0
|
63 */
|
andrew@0
|
64 typedef struct _aubio_fft_t aubio_fft_t;
|
andrew@0
|
65
|
andrew@0
|
66 /** create new FFT computation object
|
andrew@0
|
67
|
andrew@0
|
68 \param size length of the FFT
|
andrew@0
|
69
|
andrew@0
|
70 */
|
andrew@0
|
71 aubio_fft_t * new_aubio_fft(ba_uint_t size);
|
andrew@0
|
72 /** delete FFT object
|
andrew@0
|
73
|
andrew@0
|
74 \param s fft object as returned by new_aubio_fft
|
andrew@0
|
75
|
andrew@0
|
76 */
|
andrew@0
|
77 void del_aubio_fft(aubio_fft_t * s);
|
andrew@0
|
78 /** compute forward FFT
|
andrew@0
|
79
|
andrew@0
|
80 \param s fft object as returned by new_aubio_fft
|
andrew@0
|
81 \param data input signal
|
andrew@0
|
82 \param spectrum output spectrum
|
andrew@0
|
83 \param size length of the input vector
|
andrew@0
|
84
|
andrew@0
|
85 */
|
andrew@0
|
86 void aubio_fft_do (const aubio_fft_t *s, const smpl_t * data,
|
andrew@0
|
87 fft_data_t * spectrum, const ba_uint_t size);
|
andrew@0
|
88 /** compute backward (inverse) FFT
|
andrew@0
|
89
|
andrew@0
|
90 \param s fft object as returned by new_aubio_fft
|
andrew@0
|
91 \param spectrum input spectrum
|
andrew@0
|
92 \param data output signal
|
andrew@0
|
93 \param size length of the input vector
|
andrew@0
|
94
|
andrew@0
|
95 */
|
andrew@0
|
96 void aubio_fft_rdo(const aubio_fft_t *s, const fft_data_t * spectrum,
|
andrew@0
|
97 smpl_t * data, const ba_uint_t size);
|
andrew@0
|
98 /** compute norm vector from input spectrum
|
andrew@0
|
99
|
andrew@0
|
100 \param norm magnitude vector output
|
andrew@0
|
101 \param spectrum spectral data input
|
andrew@0
|
102 \param size size of the vectors
|
andrew@0
|
103
|
andrew@0
|
104 */
|
andrew@0
|
105 void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, ba_uint_t size);
|
andrew@0
|
106 /** compute phase vector from input spectrum
|
andrew@0
|
107
|
andrew@0
|
108 \param phase phase vector output
|
andrew@0
|
109 \param spectrum spectral data input
|
andrew@0
|
110 \param size size of the vectors
|
andrew@0
|
111
|
andrew@0
|
112 */
|
andrew@0
|
113 void aubio_fft_getphas(smpl_t * phase, fft_data_t * spectrum, ba_uint_t size);
|
andrew@0
|
114
|
andrew@0
|
115 /** FFT object (using cvec)
|
andrew@0
|
116
|
andrew@0
|
117 This object works similarly as aubio_fft_t, except the spectral data is
|
andrew@0
|
118 stored in a cvec_t as two vectors, magnitude and phase.
|
andrew@0
|
119
|
andrew@0
|
120 */
|
andrew@0
|
121 typedef struct _aubio_mfft_t aubio_mfft_t;
|
andrew@0
|
122
|
andrew@0
|
123 /** create new FFT computation object
|
andrew@0
|
124
|
andrew@0
|
125 \param winsize length of the FFT
|
andrew@0
|
126 \param channels number of channels
|
andrew@0
|
127
|
andrew@0
|
128 */
|
andrew@0
|
129 aubio_mfft_t * new_aubio_mfft(ba_uint_t winsize, ba_uint_t channels);
|
andrew@0
|
130 /** compute forward FFT
|
andrew@0
|
131
|
andrew@0
|
132 \param fft fft object as returned by new_aubio_mfft
|
andrew@0
|
133 \param in input signal
|
andrew@0
|
134 \param fftgrain output spectrum
|
andrew@0
|
135
|
andrew@0
|
136 */
|
andrew@0
|
137 void aubio_mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain);
|
andrew@0
|
138 /** compute backward (inverse) FFT
|
andrew@0
|
139
|
andrew@0
|
140 \param fft fft object as returned by new_aubio_mfft
|
andrew@0
|
141 \param fftgrain input spectrum (cvec)
|
andrew@0
|
142 \param out output signal
|
andrew@0
|
143
|
andrew@0
|
144 */
|
andrew@0
|
145 void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out);
|
andrew@0
|
146 /** delete FFT object
|
andrew@0
|
147
|
andrew@0
|
148 \param fft fft object as returned by new_aubio_mfft
|
andrew@0
|
149
|
andrew@0
|
150 */
|
andrew@0
|
151 void del_aubio_mfft(aubio_mfft_t * fft);
|
andrew@0
|
152
|
andrew@0
|
153
|
andrew@0
|
154 #ifdef __cplusplus
|
andrew@0
|
155 }
|
andrew@0
|
156 #endif
|
andrew@0
|
157
|
andrew@0
|
158 #endif
|