org.hermit.dsp
Class Window

java.lang.Object
  extended by org.hermit.dsp.Window

public final class Window
extends java.lang.Object

A windowing function for a discrete signal. This is used to pre-process a signal prior to FFT, in order to improve the frequency response, essentially by eliminating the discontinuities at the ends of a block of samples.


Nested Class Summary
static class Window.Function
          Definitions of the available window functions.
 
Constructor Summary
Window(int size)
          Create a window function for a given sample size.
Window(int size, Window.Function function)
          Create a window function for a given sample size.
 
Method Summary
 void transform(double[] input)
          Apply the window function to a given data block.
 void transform(double[] input, int off, int count)
          Apply the window function to a given data block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Window

public Window(int size)
Create a window function for a given sample size. This preallocates resources appropriate to that block size.

Parameters:
size - The number of samples in a block that we will be asked to transform.

Window

public Window(int size,
              Window.Function function)
Create a window function for a given sample size. This preallocates resources appropriate to that block size.

Parameters:
size - The number of samples in a block that we will be asked to transform.
function - The window function to use. Function.RECTANGULAR effectively means no transformation.
Method Detail

transform

public final void transform(double[] input)
Apply the window function to a given data block. The data in the provided buffer will be multiplied by the window function.

Parameters:
input - The input data buffer. This data will be transformed in-place by the window function.
Throws:
java.lang.IllegalArgumentException - Invalid data size.

transform

public final void transform(double[] input,
                            int off,
                            int count)
Apply the window function to a given data block. The data in the provided buffer will be multiplied by the window function.

Parameters:
input - The input data buffer. This data will be transformed in-place by the window function.
off - Offset in the buffer at which the data to be transformed starts.
count - Number of samples in the data to be transformed. Must be the same as the size parameter that was given to the constructor.
Throws:
java.lang.IllegalArgumentException - Invalid data size.