org.openuat.features
Class FPIntFFT

java.lang.Object
  extended by org.openuat.features.FPIntFFT

public class FPIntFFT
extends java.lang.Object

All data are fixed-point short integers, in which -32768 to +32768 represent -1.0 to +1.0 respectively. Integer arithmetic is used for speed, instead of the more natural floating-point. For the forward FFT (time -> freq), fixed scaling is performed to prevent arithmetic overflow, and to map a 0dB sine/cosine wave (i.e. amplitude = 32767) to two -6dB freq coefficients. The return value is always 0. For the inverse FFT (freq -> time), fixed scaling cannot be done, as two 0dB coefficients would sum to a peak amplitude of 64K, overflowing the 32k range of the fixed-point integers. Thus, the fix_fft() routine performs variable scaling, and returns a value which is the number of bits LEFT by which the output must be shifted to get the actual amplitude (i.e. if fix_fft() returns 3, each value of fr[] and fi[] must be multiplied by 8 (2**3) for proper scaling. Clearly, this cannot be done within fixed-point short integers. In practice, if the result is to be used as a filter, the scale_shift can usually be ignored, as the result will be approximately correctly normalized as is.

Author:
Tom Roberts 11/8/89, made portable Malcolm Slaney 12/15/94, enhanced Dimitrios P. Bouras 14 Jun 2006, ported to Java Rene Mayrhofer 2007-05-12

Constructor Summary
FPIntFFT()
           
 
Method Summary
static int fix_fft(short[] fr, short[] fi, short m, int off_fr, int off_fi, boolean inverse)
          fix_fft() - perform forward/inverse fast Fourier transform.
static int fix_fftr(short[] f, short m, boolean inverse)
          fix_fftr() - forward/inverse FFT on array of real numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FPIntFFT

public FPIntFFT()
Method Detail

fix_fft

public static final int fix_fft(short[] fr,
                                short[] fi,
                                short m,
                                int off_fr,
                                int off_fi,
                                boolean inverse)
fix_fft() - perform forward/inverse fast Fourier transform. fr[n],fi[n] are real and imaginary arrays, both INPUT AND RESULT (in-place FFT), with 0 <= n < 2**m; set inverse to 0 for forward transform (FFT), or 1 for iFFT.


fix_fftr

public static final int fix_fftr(short[] f,
                                 short m,
                                 boolean inverse)
fix_fftr() - forward/inverse FFT on array of real numbers. Real FFT/iFFT using half-size complex FFT by distributing even/odd samples into real/imaginary arrays respectively. In order to save data space (i.e. to avoid two arrays, one for real, one for imaginary samples), we proceed in the following two steps: a) samples are rearranged in the real array so that all even samples are in places 0-(N/2-1) and all imaginary samples in places (N/2)-(N-1), and b) fix_fft is called with fr and fi pointing to index 0 and index N/2 respectively in the original array. The above guarantees that fix_fft "sees" consecutive real samples as alternating real and imaginary samples in the complex array.



2005-2009, Rene Mayrhofer.