ddf.minim.analysis
Class FFT

java.lang.Object
  extended by ddf.minim.analysis.FourierTransform
      extended by ddf.minim.analysis.FFT

public class FFT
extends FourierTransform

FFT stands for Fast Fourier Transform. It is an efficient way to calculate the Complex Discrete Fourier Transform. There is not much to say about this class other than the fact that when you want to analyze the spectrum of an audio buffer you will almost always use this class. One restriction of this class is that the audio buffers you want to analyze must have a length that is a power of two. If you try to construct an FFT with a timeSize that is not a power of two, an IllegalArgumentException will be thrown.

Author:
Damien Di Fede
See Also:
FourierTransform, The Fast Fourier Transform

Field Summary
 
Fields inherited from class ddf.minim.analysis.FourierTransform
averages, avgPerOctave, bandWidth, BARTLETT, BARTLETTHANN, COSINE, HAMMING, HANN, imag, LANCZOS, LINAVG, LOGAVG, NOAVG, NONE, octaves, real, sampleRate, spectrum, timeSize, TRIANGULAR, TWO_PI, whichAverage, windowFunction
 
Constructor Summary
FFT(int timeSize, float sampleRate)
          Constructs an FFT that will accept sample buffers that are timeSize long and have been recorded with a sample rate of sampleRate.
 
Method Summary
protected  void allocateArrays()
           
 void forward(float[] buffer)
          Performs a forward transform on buffer.
 void forward(float[] buffReal, float[] buffImag)
          Performs a forward transform on the passed buffers.
 void inverse(float[] buffer)
          Performs an inverse transform of the frequency spectrum and places the result in buffer.
 void scaleBand(int i, float s)
          Scales the amplitude of the ith frequency band by s.
 void setBand(int i, float a)
          Sets the amplitude of the ith frequency band to a.
 
Methods inherited from class ddf.minim.analysis.FourierTransform
avgSize, calcAvg, doWindow, fillSpectrum, forward, forward, forward, freqToIndex, getAverageCenterFrequency, getAvg, getBand, getBandWidth, getFreq, indexToFreq, inverse, inverse, linAverages, logAverages, noAverages, scaleFreq, setComplex, setFreq, specSize, timeSize, window
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FFT

public FFT(int timeSize,
           float sampleRate)
Constructs an FFT that will accept sample buffers that are timeSize long and have been recorded with a sample rate of sampleRate. timeSize must be a power of two. This will throw an exception if it is not.

Parameters:
timeSize - the length of the sample buffers you will be analyzing
sampleRate - the sample rate of the audio you will be analyzing
Method Detail

allocateArrays

protected void allocateArrays()
Specified by:
allocateArrays in class FourierTransform

scaleBand

public void scaleBand(int i,
                      float s)
Description copied from class: FourierTransform
Scales the amplitude of the ith frequency band by s. You can use this to shape the spectrum before using inverse().

Specified by:
scaleBand in class FourierTransform
Parameters:
i - the frequency band to modify
s - the scaling factor

setBand

public void setBand(int i,
                    float a)
Description copied from class: FourierTransform
Sets the amplitude of the ith frequency band to a. You can use this to shape the spectrum before using inverse().

Specified by:
setBand in class FourierTransform
Parameters:
i - the frequency band to modify
a - the new amplitude

forward

public void forward(float[] buffer)
Description copied from class: FourierTransform
Performs a forward transform on buffer.

Specified by:
forward in class FourierTransform
Parameters:
buffer - the buffer to analyze

forward

public void forward(float[] buffReal,
                    float[] buffImag)
Performs a forward transform on the passed buffers.

Parameters:
buffReal - the real part of the time domain signal to transform
buffImag - the imaginary part of the time domain signal to transform

inverse

public void inverse(float[] buffer)
Description copied from class: FourierTransform
Performs an inverse transform of the frequency spectrum and places the result in buffer.

Specified by:
inverse in class FourierTransform
Parameters:
buffer - the buffer to place the result of the inverse transform in