com.oregondsp.signalProcessing.filter.fir
Class ComplexOverlapAdd

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

public class ComplexOverlapAdd
extends java.lang.Object

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

This overlap add algorithm (see Oppenheim and Schafer, Digital Signal Processing, 1975) enables complex FIR filters to operate on complex 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 complex FFT algorithms required to implement the convolution operation.

The complex DFT object may be large if the chosen processing block size is large. If more than one ComplexOverlapAdd 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 complex DFT used in another "master" ComplexOverlapAdd 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 ComplexOverlapAdd 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.


Constructor Summary
ComplexOverlapAdd(float[] Hr, float[] Hi, ComplexOverlapAdd master)
          Constructor for a slave ComplexOverlapAdd instance
ComplexOverlapAdd(float[] Hr, float[] Hi, int blockSize)
          Constructor for a master ComplexOverlapAdd instance
 
Method Summary
 void filter(float[] dataR, float[] dataI, int dptr, float[] outR, float[] outI, int optr)
          Filtering operation to produce an incremental convolution result from one block of data
 void flush(float[] outR, float[] outI, int optr)
          Flushes state information buffer - i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComplexOverlapAdd

public ComplexOverlapAdd(float[] Hr,
                         float[] Hi,
                         int blockSize)
Constructor for a master ComplexOverlapAdd instance

Parameters:
Hr - float[] containing real part of kernel
Hi - float[] containing imaginary part of kernel
blockSize - int specifying size of data blocks to be filtered

ComplexOverlapAdd

public ComplexOverlapAdd(float[] Hr,
                         float[] Hi,
                         ComplexOverlapAdd master)
Constructor for a slave ComplexOverlapAdd instance

Parameters:
Hr - float[] containing the real part of kernel
Hi - float[] containing the imaginary part of kernel
master - ComplexOverlapAdd instance from which fft is acquired
Method Detail

filter

public void filter(float[] dataR,
                   float[] dataI,
                   int dptr,
                   float[] outR,
                   float[] outI,
                   int optr)
Filtering operation to produce an incremental convolution result from one block of data

Parameters:
dataR - float[] containing real part of data block. The length of this array must be at least dptr + blockSize.
dataI - float[] containing imaginary part of data block. The length of this array must be at least dptr + blockSize.
dptr - int specifying the point within the data arrays where block begins (usually 0)
outR - float[] containing the real increment of the convolution result. The array length must be at least optr + blockSize.
outI - float[] containing the imaginary increment of the convolution result. The array length must be at least optr + blockSize.
optr - int specifying point in output array where convolution result starts.

flush

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

Parameters:
outR - float[] containing the real increment of the convolution result. The array length must be at least optr + blockSize.
outI - float[] containing the imaginary increment of the convolution result. The array length must be at least optr + blockSize.
optr - int specifying the point in the output array where the convolution result starts.