com.icdif.audio.analysis
Class SpectralDifference

java.lang.Object
  extended by com.icdif.audio.analysis.SpectralDifference

public class SpectralDifference
extends java.lang.Object

This class is meant to do the calculations needed to obtain a spectral difference (or spectral flux) function. The Spectral flux is a measure of how quickly the power spectrum of a signal is changing, calculated by comparing the power spectrum for one window against the power spectrum from the previous window.

Author:
wanderer

Constructor Summary
SpectralDifference(AudioDecoder decoder, int sampleWindowSize, int hopSize, boolean isHamming, int sampleRate)
          Initiates this class, by supplying the the parameters needed
 
Method Summary
 FFT getFft()
          Gets the instance of the FFT used for calculus
 java.util.ArrayList<java.lang.Float> getSpectralDifference()
          Gets the Spectral Difference (a function that measures how quickly the power spectrum of a signal is changing)
 java.util.ArrayList<java.lang.Float> getTotalSamples()
          Gets the total samples used to calculate the Spectral Difference
 float[] nextSpectrum()
          Calculates the spectrum of the samples, by using the Fourier Transform and an hoping margin defined in the constructor, returning the spectrum or null, when there is no more data to read.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpectralDifference

public SpectralDifference(AudioDecoder decoder,
                          int sampleWindowSize,
                          int hopSize,
                          boolean isHamming,
                          int sampleRate)
Initiates this class, by supplying the the parameters needed

Parameters:
decoder - The AudioDecoder that will supply the samples
sampleWindowSize - The size of the window
hopSize - The size of the overlap (it has to be minor than the sampleWindow)
isHamming - If the samples are to be smoothed in the FFT by the use of the Hamming Function
sampleRate - The sample rate of the audio
Method Detail

nextSpectrum

public float[] nextSpectrum()
Calculates the spectrum of the samples, by using the Fourier Transform and an hoping margin defined in the constructor, returning the spectrum or null, when there is no more data to read.

Returns:
The next Spectrum or null

getFft

public FFT getFft()
Gets the instance of the FFT used for calculus

Returns:
the FFT instance used for calculus

getSpectralDifference

public java.util.ArrayList<java.lang.Float> getSpectralDifference()
Gets the Spectral Difference (a function that measures how quickly the power spectrum of a signal is changing)

Returns:
the spectralDifference

getTotalSamples

public java.util.ArrayList<java.lang.Float> getTotalSamples()
Gets the total samples used to calculate the Spectral Difference

Returns:
the totalSamples