be.hogent.tarsos.dsp.util
Class FFT

java.lang.Object
  extended by be.hogent.tarsos.dsp.util.FFT

public final class FFT
extends java.lang.Object

Wrapper for calling a hopefully Fast Fourier transform. Makes it easy to switch FFT algorithm with minimal overhead.

Author:
Joren Six

Constructor Summary
FFT(int size)
           
 
Method Summary
 void backwardsTransform(float[] data)
          Computes inverse DFT.
 double binToHz(int binIndex, float sampleRate)
           
 void forwardTransform(float[] data)
          Computes forward DFT.
 void modulus(float[] data, float[] amplitudes)
          Calculates the the modulus for each element in data and stores the result in amplitudes.
 float modulus(float[] data, int index)
          Returns the modulus of the element at index bufferCount.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FFT

public FFT(int size)
Method Detail

forwardTransform

public void forwardTransform(float[] data)
Computes forward DFT.

Parameters:
data - data to transform.

backwardsTransform

public void backwardsTransform(float[] data)
Computes inverse DFT.

Parameters:
data - data to transform

binToHz

public double binToHz(int binIndex,
                      float sampleRate)

modulus

public float modulus(float[] data,
                     int index)
Returns the modulus of the element at index bufferCount. The modulus, magnitude or absolute value is (a²+b²) ^ 0.5 with a being the real part and b the imaginary part of a complex number.

Parameters:
data - The FFT transformed data.
index - The index of the element.
Returns:
The modulus, magnitude or absolute value of the element at index bufferCount

modulus

public void modulus(float[] data,
                    float[] amplitudes)
Calculates the the modulus for each element in data and stores the result in amplitudes.

Parameters:
data - The input data.
amplitudes - The output modulus info or amplitude.