com.oregondsp.signalProcessing.filter.fir
Class OverlapAdd

java.lang.Object
  extended by com.oregondsp.signalProcessing.filter.fir.OverlapAdd

public class OverlapAdd
extends java.lang.Object

Implements a finite impulse response (FIR) filter using the overlap-add algorithm.

The overlap add algorithm (see Oppenheim and Schafer, Digital Signal Processing, 1975) enables FIR filters to operate on sequences of arbitrary length when the sequences are available in a series of uniform consecutive, contiguous blocks. The output is produced incrementally with the filter() method, filtering one block at a time. The algorithm is capable of filtering data from continuous, real-time streams or streams from very large archive files. However, it is suitable for filtering data segments of any length (including short, extracted event segments).

The size of the sequential data blocks must be uniform (i.e. the same from one invocation of filter() to the next). The block size is specified in the first constructor, which uses it and the filter kernel size to calculate the size of the forward and inverse FFT algorithms required to implement the convolution operation.

The DFT object may be large if the chosen processing block size is large. If more than one OverlapAdd instance is to be used in an application, it may be worthwhile to share fft resources among instances, which is possible provided the kernel sizes of the FIR filters are identical. For this case, a second constructor is provided that constructs a "slave" instance containing a reference to the DFT used in another "master" OverlapAdd instance. Slave instances use the DFT resources of their associated master instances. Care should be taken to keep master and slave instances in the same thread.

The OverlapAdd class keeps state information from one invocation of filter() to the next on consecutive blocks of the data stream. This state information allows the algorithm to perform continuous convolutions on streams of arbitrary length, including real-time streams. If and when the end of the stream is reached, the remaining state information may be dumped using the flush() method.

An example of the application of the OverlapAdd class is available in the Interpolator class.


Constructor Summary
OverlapAdd(float[] H, int blockSize)
          Constructor for master OverlapAdd instance - this one has the fft instances.
OverlapAdd(float[] H, OverlapAdd master)
          Constructor for slave OverlapAdd instance - this one uses the fft instance contained in the master
 
Method Summary
 void filter(float[] src, int sptr, float[] dst, int dptr)
          Filtering operation to produce an incremental convolution result from one block of data
 void flush(float[] dst, int dptr)
          Flushes state information buffer - i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OverlapAdd

public OverlapAdd(float[] H,
                  int blockSize)
Constructor for master OverlapAdd instance - this one has the fft instances.

Parameters:
H - float[] containing convolutional kernel
blockSize - int specifying size of data blocks to be filtered

OverlapAdd

public OverlapAdd(float[] H,
                  OverlapAdd master)
Constructor for slave OverlapAdd instance - this one uses the fft instance contained in the master

Parameters:
H - Float array containing kernel
master - Master OverlapAdd instance - slave obtains fft instances from the master
Method Detail

filter

public void filter(float[] src,
                   int sptr,
                   float[] dst,
                   int dptr)
Filtering operation to produce an incremental convolution result from one block of data

Parameters:
src - float[] array containing data block
sptr - int specifying point within data array to begin block (usually 0). Array length must be at least blocksize + sptr.
dst - float[] containing increment of convolution result - array length must be at least dptr + blockSize
dptr - Point within destination array where convolution result starts

flush

public void flush(float[] dst,
                  int dptr)
Flushes state information buffer - i.e. left over convolution results when no further data blocks are available

Parameters:
dst - float[] where convolution results are returned. Length of dst must be >= dptr + blockSize.
dptr - int specifying point in dst where convolution results begin.