Class WindowFunction

  extended by ddf.minim.analysis.WindowFunction
Direct Known Subclasses:
BartlettHannWindow, BartlettWindow, BlackmanWindow, CosineWindow, GaussWindow, HammingWindow, HannWindow, LanczosWindow, RectangularWindow, TriangularWindow

public abstract class WindowFunction
extends java.lang.Object

A Window function represents a curve which is applied to a sample buffer to reduce the introduction of spectral leakage in the Fourier transform.


Windowing is the process of shaping the audio samples before transforming them to the frequency domain. The Fourier Transform assumes the sample buffer is is a repetitive signal, if a sample buffer is not truly periodic within the measured interval sharp discontinuities may arise that can introduce spectral leakage. Spectral leakage is the speading of signal energy across multiple FFT bins. This "spreading" can drown out narrow band signals and hinder detection.

A windowing function attempts to reduce spectral leakage by attenuating the measured sample buffer at its end points to eliminate discontinuities. If you call the window() function with an appropriate WindowFunction, such as HammingWindow(), the sample buffers passed to the object for analysis will be shaped by the current window before being transformed. The result of using a window is to reduce the leakage in the spectrum somewhat.

WindowFunction handles work associated with various window functions such as the Hamming window. To create your own window function you must extend WindowFunction and implement the value method which defines the shape of the window at a given offset. WindowFunction will call this method to apply the window to a sample buffer. The number passed to the method is an offset within the length of the window curve.

Damien Di Fede, Corban Brook

Field Summary
protected  int length
protected static float TWO_PI
          The float value of 2*PI.
Constructor Summary
Method Summary
 void apply(float[] samples)
          Apply the window function to a sample buffer.
 float[] generateCurve(int length)
          Generates the curve of the window function.
protected abstract  float value(int length, int index)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected static final float TWO_PI
The float value of 2*PI. Provided as a convenience for subclasses.

See Also:
Constant Field Values


protected int length
Constructor Detail


public WindowFunction()
Method Detail


public void apply(float[] samples)
Apply the window function to a sample buffer.

samples - a sample buffer


public float[] generateCurve(int length)
Generates the curve of the window function.

length - the length of the window
the shape of the window function


protected abstract float value(int length,
                               int index)