Class WindowFunction

java.lang.Object
be.tarsos.dsp.util.fft.WindowFunction
Direct Known Subclasses:
BartlettHannWindow, BartlettWindow, BlackmanHarrisNuttall, BlackmanWindow, CosineWindow, GaussWindow, HammingWindow, HannWindow, LanczosWindow, RectangularWindow, ScaledHammingWindow, 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

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.

Author:
Damien Di Fede, Corban Brook
  • Constructor Summary

    Constructors 
    Constructor Description
    WindowFunction()  
  • Method Summary

    Modifier and Type Method Description
    void apply​(float[] samples)
    Apply the window function to a sample buffer.
    float[] generateCurve​(int length)
    Generates the curve of the window function.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • apply

      public void apply​(float[] samples)
      Apply the window function to a sample buffer.
      Parameters:
      samples - a sample buffer
    • generateCurve

      public float[] generateCurve​(int length)
      Generates the curve of the window function.
      Parameters:
      length - the length of the window
      Returns:
      the shape of the window function