FFT(3SP)

NAME
FloatFFT, TrigRecombFFT, FFT - Fast Fourier transform (FFT) routines

SYNOPSIS

#include <speech.h>

int ComputeDFT (short *wav, int wavlen, int offset, int winsize,
                int inc, int coeffs, double alpha, int *numframes)

int FloatFFT (float *x, Complex *y, int m)

int TrigRecombFFT (Complex *x, Complex *y, int m)

int FFT (Complex *x, int m)

DESCRIPTION

These routines perform Fast Fourier Transforms (FFT) on varius types of data. All of the routines require that the length of the input data be a power of two.

ComputeDFT() computes a DFT for the waveform wav of length wavlen using a window size of winsize and increment of inc. offset is the offset relative from the beginning of wav where the DFT should start. offset can be negative. wav, wavlen, and offset units are data points. coeffs is the number of coefficients in the resulting DFT. If alpha is non-zero then preemphasis is done and alpha is the alpha value used. ComputeDFT() returns a pointer to the computed DFT structure ( Alloc2d(3SP) ). The total number of frames calculated is returned in numframes . If an error has occured then a NULL is returned and ErrorStr(3SP) is set.

FloatFFT() takes an array of floats pointed to by x and places the resulting FFT in y. m is log base 2 of the length of x. y should be half the length of x. FFT values for frequencies above the nyquist rate are symmetrical with those below, so only the bottom half is computed. FloatFFT uses TrigRecombFFT.

TrigRecombFFT() is optimized for real input data. N real numbers should be packed into N/2 complex numbers before calling TrigRecombFFT() as follows:

    x[i].real = input[i*2];       /* even elements */
    x[i].imag = input[i*2 + 1];   /* odd elements  */

The results are placed in y and are equal to the first 2**m values of a regular FFT performed on 2**(m+1) complex numbers with real part equal to the real input and imaginary part equal to 0. m is log base 2 of the length of x and y. (So there are 2**(m+1) real values.) The TrigRecombFFT() routine uses FFT().

FFT() performs an in-place radix 2 decimation in time FFT on x. m is log base 2 of the length of x. The resluting FFT is placed in x (so the original data is destroyed).

EXAMPLES
dft = ComputeDFT (data, length, 0, 128, 64, 64, 0.98, &frames)

DIAGNOSTICS

FloatFFT(), TrigRecombFFT(), andd FFT() return a negative number on error and sets ErrorString.

SEE ALSO
ErrorString(3SP), Preemphasis(3SP), malloc(3), Alloc2d(3), free(3), Free2d(3),

BUGS

AUTHORS
These routines were taken from C Language Algorithms for Digital Signal Processing by Paul M. Embree and Bruce Kimble.