net.beadsproject.beads.analysis.featureextractors
Class FFT

java.lang.Object
  extended by net.beadsproject.beads.core.Bead
      extended by net.beadsproject.beads.analysis.FeatureExtractor<float[][],float[]>
          extended by net.beadsproject.beads.analysis.featureextractors.FFT

public class FFT
extends FeatureExtractor<float[][],float[]>

FFT performs a Fast Fourier Transform and forwards the complex data to any listeners. The complex data is a float of the form float[2][frameSize], with real and imaginary parts stored respectively.


Field Summary
protected  float[] fftImag
          The imaginary part.
protected  float[] fftReal
          The real part.
 
Fields inherited from class net.beadsproject.beads.analysis.FeatureExtractor
featureDescriptions, features, name, numFeatures
 
Constructor Summary
FFT()
          Instantiates a new FFT.
 
Method Summary
static float binFrequency(float samplingFrequency, int blockSize, float binNumber)
          The frequency corresponding to a specific bin
static float binNumber(float samplingFrequency, int blockSize, float freq)
          Returns the average bin number corresponding to a particular frequency.
protected static float[] calculateImaginary(float[] spectrum, int length)
          Gets the imaginary part from the complex spectrum.
protected static float[] calculateReal(float[] spectrum, int length)
          Gets the real part from the complex spectrum.
protected static void fft(float[] data, int n, boolean isign)
           
static float nyquist(float samplingFrequency)
          The nyquist frequency for this samplingFrequency
 void process(TimeStamp startTime, TimeStamp endTime, float[] data)
          Process some data of type P (specified by the class def).
 
Methods inherited from class net.beadsproject.beads.analysis.FeatureExtractor
addListener, forward, getFeatureDescriptions, getFeatures, getName, getNumberOfFeatures, removeListener, setName, setNumberOfFeatures
 
Methods inherited from class net.beadsproject.beads.core.Bead
getKillListener, isDeleted, isPaused, kill, message, messageReceived, pause, setKillListener, start, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fftReal

protected float[] fftReal
The real part.


fftImag

protected float[] fftImag
The imaginary part.

Constructor Detail

FFT

public FFT()
Instantiates a new FFT.

Method Detail

process

public void process(TimeStamp startTime,
                    TimeStamp endTime,
                    float[] data)
Description copied from class: FeatureExtractor
Process some data of type P (specified by the class def). This method must be overidden by implementing classes.

Specified by:
process in class FeatureExtractor<float[][],float[]>
data - the data.

binFrequency

public static float binFrequency(float samplingFrequency,
                                 int blockSize,
                                 float binNumber)
The frequency corresponding to a specific bin

Parameters:
samplingFrequency - The Sampling Frequency of the AudioContext
blockSize - The size of the block analysed
binNumber -

binNumber

public static float binNumber(float samplingFrequency,
                              int blockSize,
                              float freq)
Returns the average bin number corresponding to a particular frequency. Note: This function returns a float. Take the Math.round() of the returned value to get an integral bin number.

Parameters:
samplingFrequency - The Sampling Frequency of the AudioContext
blockSize - The size of the fft block
freq - The frequency

nyquist

public static float nyquist(float samplingFrequency)
The nyquist frequency for this samplingFrequency


calculateReal

protected static float[] calculateReal(float[] spectrum,
                                       int length)
Gets the real part from the complex spectrum.

Parameters:
spectrum - complex spectrum.
length - length of data to use.
Returns:
real part of given length of complex spectrum.

calculateImaginary

protected static float[] calculateImaginary(float[] spectrum,
                                            int length)
Gets the imaginary part from the complex spectrum.

Parameters:
spectrum - complex spectrum.
length - length of data to use.
Returns:
imaginary part of given length of complex spectrum.

fft

protected static void fft(float[] data,
                          int n,
                          boolean isign)