jAudioFeatureExtractor.jAudioTools
Class FFT

java.lang.Object
  extended by jAudioFeatureExtractor.jAudioTools.FFT

public class FFT
extends java.lang.Object

This class performs a complex to complex Fast Fourier Transform. Forward and inverse transforms may both be performed. The transforms may be performed with or without the application of a Hanning window.

The FFT is performed by this class' constructor. The real and imaginary results are both stored, and the magnitude spectrum, power spectrum and phase angles may also be accessed (along with appropriate frequency bin labels for the magnitude and power spectra).

Author:
Cory McKay

Constructor Summary
FFT(double[] real_input, double[] imaginary_input, boolean inverse_transform, boolean use_hanning_window)
          Performs the Fourier transform and stores the real and imaginary results.
 
Method Summary
 double[] getBinLabels(double sampling_rate)
          Returns the frequency bin labels for each bin referred to by the real values, imaginary values, magnitudes and phase angles as determined by the given sampling rate.
 double[] getImaginaryValues()
          Returns the real values as calculated by the FFT.
 double[] getMagnitudeSpectrum()
          Returns the magnitudes spectrum.
 double[] getPhaseAngles()
          Returns the phase angle for each frequency bin.
 double[] getPowerSpectrum()
          Returns the power spectrum.
 double[] getRealValues()
          Returns the real values as calculated by the FFT.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FFT

public FFT(double[] real_input,
           double[] imaginary_input,
           boolean inverse_transform,
           boolean use_hanning_window)
    throws java.lang.Exception
Performs the Fourier transform and stores the real and imaginary results. Input signals are zero-padded if they do not have a length equal to a power of 2.

Parameters:
real_input - The real part of the signal to be transformed.
imaginary_input - The imaginary part of the signal to be. transformed. This may be null if the signal is entirely real.
inverse_transform - A value of false implies that a forward transform is to be applied, and a value of true means that an inverse transform is tob be applied.
use_hanning_window - A value of true means that a Hanning window will be applied to the real_input. A value of valse will result in the application of a Hanning window.
Throws:
java.lang.Exception - Throws an exception if the real and imaginary inputs are of different sizes or if less than three input samples are provided.
Method Detail

getMagnitudeSpectrum

public double[] getMagnitudeSpectrum()
Returns the magnitudes spectrum. It only makes sense to call this method if this object was instantiated as a forward Fourier transform.

Only the left side of the spectrum is returned, as the folded portion of the spectrum is redundant for the purpose of the magnitude spectrum. This means that the bins only go up to half of the sampling rate.

Returns:
The magnitude of each frequency bin.

getPowerSpectrum

public double[] getPowerSpectrum()
Returns the power spectrum. It only makes sense to call this method if this object was instantiated as a forward Fourier transform.

Only the left side of the spectrum is returned, as the folded portion of the spectrum is redundant for the purpose of the power spectrum. This means that the bins only go up to half of the sampling rate.

Returns:
The magnitude of each frequency bin.

getPhaseAngles

public double[] getPhaseAngles()
Returns the phase angle for each frequency bin. It only makes sense to call this method if this object was instantiated as a forward Fourier transform.

Only the left side of the spectrum is returned, as the folded portion of the spectrum is redundant for the purpose of the phase angles. This means that the bins only go up to half of the sampling rate.

Returns:
The phase angle for each frequency bin in degrees.

getBinLabels

public double[] getBinLabels(double sampling_rate)
Returns the frequency bin labels for each bin referred to by the real values, imaginary values, magnitudes and phase angles as determined by the given sampling rate.

Parameters:
sampling_rate - The sampling rate that was used to perform the FFT.
Returns:
The bin labels.

getRealValues

public double[] getRealValues()
Returns the real values as calculated by the FFT.

Returns:
The real values.

getImaginaryValues

public double[] getImaginaryValues()
Returns the real values as calculated by the FFT.

Returns:
The real values.