public abstract class WindowFunction
extends java.lang.Object
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.
Constructor and Description |
---|
WindowFunction() |
Modifier and Type | Method and Description |
---|---|
void |
apply(float[] samples)
Apply the window function to a sample buffer.
|
float[] |
generateCurve(int length)
Generates the curve of the window function.
|
public void apply(float[] samples)
samples
- a sample bufferpublic float[] generateCurve(int length)
length
- the length of the window