Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_fft.h
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 /**@name Fast Fourier Transform functions
43 
44 <para>
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 </para>
51 
52 <formalpara> <title>What is a Fourier Transform ?</title>
53 
54 <para>
55 The Fourier transform of a signal gives us a frequency-domain
56 representation of a time-domain signal. In discrete time, the Fourier
57 Transform is called a Discrete Fourier Transform (DFT) and is given
58 by:
59 
60 \[y_k = \sum_{t=0}^{n-1} x_t \; \omega_{n}^{kt} \; ; \; k=0...n-1 \]
61 
62 where \(y = (y_0,y_1,... y_{n-1})\) is the DFT (of order \(n\) ) of the
63 signal \(x = (x_0,x_1,... x_{n-1})\), where
64 \(\omega_{n}^{0},\omega_{n}^{1},... \omega_{n}^{n-1}\) are the n
65 complex nth roots of 1.
66 </para>
67 
68 <para>
69 The Fast Fourier Transform (FFT) is a very efficient implementation of
70 a Discrete Fourier Transform. See, for example "Algorithms" by Thomas
71 H. Cormen, Charles E. Leiserson and Ronald L. Rivest (pub. MIT Press),
72 or any signal processing textbook.
73 </para>
74 
75 </formalpara>
76 
77 */
78 
79 //@{
80 
81 /** Basic in-place FFT.
82 
83 <para>There's no point actually using this - use \Ref{fastFFT}
84 instead. However, the code in this function closely matches the
85 classic FORTRAN version given in many text books, so is at least easy
86 to follow for new users.</para>
87 
88 <para>The length of <parameter>real</parameter> and
89 <parameter>imag</parameter> must be the same, and must be a power of 2
90 (e.g. 128).</para>
91 
92 @see slowIFFT
93 @see FastFFT */
94 int slowFFT(EST_FVector &real, EST_FVector &imag);
95 
96 /** Alternate name for slowFFT
97 */
98 inline int FFT(EST_FVector &real, EST_FVector &imag){
99  return slowFFT(real, imag);
100 }
101 
102 /** Basic inverse in-place FFT
103 int slowFFT
104 */
105 int slowIFFT(EST_FVector &real, EST_FVector &imag);
106 
107 /** Alternate name for slowIFFT
108 */
109 inline int IFFT(EST_FVector &real, EST_FVector &imag){
110  return slowIFFT(real, imag);
111 }
112 
113 /** Power spectrum using the fastFFT function.
114 The power spectrum is simply the squared magnitude of the
115 FFT. The result real and imaginary parts are both set equal
116 to the power spectrum (you only need one of them !)
117 */
118 int power_spectrum(EST_FVector &real, EST_FVector &imag);
119 
120 /** Power spectrum using the slowFFT function
121 */
122 int power_spectrum_slow(EST_FVector &real, EST_FVector &imag);
123 
124 /** Fast FFT
125 An optimised implementation by Tony Robinson to be used
126 in preference to slowFFT
127 */
128 int fastFFT(EST_FVector &invec);
129 
130 // Auxiliary for fastFFT
131 int fastlog2(int);
132 
133 //@}
134 
135 
136 #endif // __EST_FFT_H__
137