Edinburgh Speech Tools 2.4-release
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>
45These are the low level functions where the actual FFT is
46performed. Both slow and fast implementations are available for
47historical reasons. They have identical functionality. At this time,
48vectors of complex numbers are handled as pairs of vectors of real and
49imaginary numbers.
50</para>
51
52<formalpara> <title>What is a Fourier Transform ?</title>
53
54<para>
55The Fourier transform of a signal gives us a frequency-domain
56representation of a time-domain signal. In discrete time, the Fourier
57Transform is called a Discrete Fourier Transform (DFT) and is given
58by:
59
60\[y_k = \sum_{t=0}^{n-1} x_t \; \omega_{n}^{kt} \; ; \; k=0...n-1 \]
61
62where \‍(y = (y_0,y_1,... y_{n-1})\‍) is the DFT (of order \‍(n\‍) ) of the
63signal \‍(x = (x_0,x_1,... x_{n-1})\‍), where
64\‍(\omega_{n}^{0},\omega_{n}^{1},... \omega_{n}^{n-1}\‍) are the n
65complex nth roots of 1.
66</para>
67
68<para>
69The Fast Fourier Transform (FFT) is a very efficient implementation of
70a Discrete Fourier Transform. See, for example "Algorithms" by Thomas
71H. Cormen, Charles E. Leiserson and Ronald L. Rivest (pub. MIT Press),
72or 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}
84instead. However, the code in this function closely matches the
85classic FORTRAN version given in many text books, so is at least easy
86to 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 */
94int slowFFT(EST_FVector &real, EST_FVector &imag);
95
96/** Alternate name for slowFFT
97*/
98inline int FFT(EST_FVector &real, EST_FVector &imag){
99 return slowFFT(real, imag);
100}
101
102/** Basic inverse in-place FFT
103int slowFFT
104*/
105int slowIFFT(EST_FVector &real, EST_FVector &imag);
106
107/** Alternate name for slowIFFT
108*/
109inline int IFFT(EST_FVector &real, EST_FVector &imag){
110 return slowIFFT(real, imag);
111}
112
113/** Power spectrum using the fastFFT function.
114The power spectrum is simply the squared magnitude of the
115FFT. The result real and imaginary parts are both set equal
116to the power spectrum (you only need one of them !)
117*/
118int power_spectrum(EST_FVector &real, EST_FVector &imag);
119
120/** Power spectrum using the slowFFT function
121*/
122int power_spectrum_slow(EST_FVector &real, EST_FVector &imag);
123
124/** Fast FFT
125An optimised implementation by Tony Robinson to be used
126in preference to slowFFT
127*/
128int fastFFT(EST_FVector &invec);
129
130// Auxiliary for fastFFT
131int fastlog2(int);
132
133//@}
134
135
136#endif // __EST_FFT_H__
137