Edinburgh Speech Tools  2.1-release
EST_fft.h
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1995,1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 
34 
35 #ifndef __EST_FFT_H__
36 #define __EST_FFT_H__
37 
38 #include "EST_Wave.h"
39 #include "EST_Track.h"
40 #include "EST_FMatrix.h"
41 
42 /**@defgroup FastFourierTransformfunctions Fast Fourier Transform functions
43  @ingroup FunctionsForGeneratingFrames
44 
45 These are the low level functions where the actual FFT is
46 performed. Both slow and fast implementations are available for
47 historical reasons. They have identical functionality. At this time,
48 vectors of complex numbers are handled as pairs of vectors of real and
49 imaginary numbers.
50 
51 ### What is a Fourier Transform ?
52 
53 The Fourier transform of a signal gives us a frequency-domain
54 representation of a time-domain signal. In discrete time, the Fourier
55 Transform is called a Discrete Fourier Transform (DFT) and is given
56 by:
57 
58 \f[y_k = \sum_{t=0}^{n-1} x_t \; \omega_{n}^{kt} \; ; \; k=0...n-1 \f]
59 
60 where \f$y = (y_0,y_1,... y_{n-1})\f$ is the DFT (of order \f$n\f$ ) of the
61 signal \f$x = (x_0,x_1,... x_{n-1})\f$, where
62 \f$\omega_{n}^{0},\omega_{n}^{1},... \omega_{n}^{n-1}\f$ are the n
63 complex nth roots of 1.
64 
65 
66 The Fast Fourier Transform (FFT) is a very efficient implementation of
67 a Discrete Fourier Transform. See, for example "Algorithms" by Thomas
68 H. Cormen, Charles E. Leiserson and Ronald L. Rivest (pub. MIT Press),
69 or any signal processing textbook.
70 
71 */
72 
73 ///@{
74 
75 /** \brief Basic in-place FFT.
76 
77 There's no point actually using this - use \ref fastFFT
78 instead. However, the code in this function closely matches the
79 classic FORTRAN version given in many text books, so is at least easy
80 to follow for new users.
81 
82 The length of real and imag must be the same, and must be
83 a power of 2 (e.g. 128).
84 
85 @see slowIFFT
86 @see FastFFT */
87 int slowFFT(EST_FVector &real, EST_FVector &imag);
88 
89 /** \brief Alternate name for slowFFT
90 */
91 inline int FFT(EST_FVector &real, EST_FVector &imag){
92  return slowFFT(real, imag);
93 }
94 
95 /** \brief Basic inverse in-place FFT
96 */
97 int slowIFFT(EST_FVector &real, EST_FVector &imag);
98 
99 /** \brief Alternate name for slowIFFT
100 */
101 inline int IFFT(EST_FVector &real, EST_FVector &imag){
102  return slowIFFT(real, imag);
103 }
104 
105 /** \brief Power spectrum using the fastFFT function.
106 
107 The power spectrum is simply the squared magnitude of the
108 FFT. The result real and imaginary parts are both set equal
109 to the power spectrum (you only need one of them!)
110 */
111 int power_spectrum(EST_FVector &real, EST_FVector &imag);
112 
113 /** \brief Power spectrum using the slowFFT function
114 */
116 
117 /** \brief Fast FFT
118 An optimised implementation by Tony Robinson to be used
119 in preference to slowFFT
120 */
121 int fastFFT(EST_FVector &invec);
122 
123 // Auxiliary for fastFFT
124 int fastlog2(int);
125 
126 ///@}
127 
128 
129 #endif // __EST_FFT_H__
130 
int IFFT(EST_FVector &real, EST_FVector &imag)
Alternate name for slowIFFT.
Definition: EST_fft.h:101
A vector class for floating point numbers. EST_FVector x should be used instead of float *x wherever ...
Definition: EST_FMatrix.h:119
int slowFFT(EST_FVector &real, EST_FVector &imag)
Basic in-place FFT.
Definition: fft.cc:173
int fastlog2(int)
Definition: fft.cc:555
int fastFFT(EST_FVector &invec)
Fast FFT An optimised implementation by Tony Robinson to be used in preference to slowFFT...
Definition: fft.cc:256
int slowIFFT(EST_FVector &real, EST_FVector &imag)
Basic inverse in-place FFT.
Definition: fft.cc:179
int power_spectrum_slow(EST_FVector &real, EST_FVector &imag)
Power spectrum using the slowFFT function.
Definition: fft.cc:209
int FFT(EST_FVector &real, EST_FVector &imag)
Alternate name for slowFFT.
Definition: EST_fft.h:91
int power_spectrum(EST_FVector &real, EST_FVector &imag)
Power spectrum using the fastFFT function.
Definition: fft.cc:222