class FIRFilter : public Pipe

Digital FIR filter implementation API.

Inheritance:


Public Methods

FIRFilter(void)
Default constructor.
FIRFilter(int length, float Sample)
Construct an empty filter instance.
FIRFilter(const FIRFilter& model)
Copy constructor.
~FIRFilter()
Filter destructor.
TSeries operator)(const TSeries& in)
Filter a Time Series.
void dataCheck(const TSeries& ts) const
Check input data validity.
Time getCurrentTime(void) const
Get the current time.
int getLength(void) const throw()
Get the filter length.
double getRate(void) const throw()
Get the sample rate.
Time getStartTime(void) const
Get the start time.
bool getStat(void) const throw()
Test the history status.
bool inUse(void) const
Test the filter acitivity status.
void dump(ostream& ostr) const throw()
Print the Filter status.
TSeries apply(const TSeries& in)
Filter a Time Series.
TSeries& apply(const TSeries& in, TSeries& out) throw(invalid_argument)
Filter a TSeries into an output object.
void apply(int N, const float* in, float* out)
Filter a float array.
void apply(int N, const fComplex* in, fComplex* out)
Filter a float array.
void reset(void)
Set filter coefficients.
FIRFilter& operator=(const FIRFilter& model) throw()
Copy constructor.
void setCoefs(int N, const double* Coefs) throw()
Set filter coefficients.
void setHistory(int N, const float* Hist=0, Time t=Time(0)) throw()
Set history.
void setHistory(int N, const fComplex* Hist, Time t=Time(0)) throw()
Set history.
void setLength(int N) throw()
Set Length.
void setRate(double F) throw()
Set the filter sample Rate.
FSeries Xfer(float Fmin=0.0, float Fmax=0.0, float dF=1.0) const throw()
Get the transfer function of a Filter.

Inherited from Pipe:

Public Methods

virtual bool isDataValid(const TSeries& in) const
KeyChain& getInputKeys(void) const
KeyChain& getOutputKeys(void) const

Inherited from FilterBase:

Public Methods

virtual bool rootGetStartTime(Time& t) const throw()
virtual bool rootGetCurrentTime(Time& t) const throw()

Documentation

The Filter class object implements a digital FIR filter that can be used to filter time series (TSeries) data. Filter class instances carry the signal history as well as the filter coefficients to prevent the introduction of edge effect when filtering a long series in serveral pieces. Each signal (channel) to be filtered must use a separate Filter instance.
FIRFilter(void)
Default constructor. No coefficient or history storage is allocated.

FIRFilter(int length, float Sample)
A real-valued Order 'length'-1 digital FIR filter is constructed which will operate on data sampled with specified frequency. The filter coefficients remain uninitialized and the history data is cleared.
Parameters:
length - Number of terms (zeros) in the filter.
Sample - Nominal sampling rate.

FIRFilter(const FIRFilter& model)
A filter is constructed with the same length, frequency and coefficients as the argument Filter. The history is zeroed.
Parameters:
model - Filter to be copied.

~FIRFilter()
Destroy the filter object and release any memory allocated for filter coefficients or history information.

TSeries operator)(const TSeries& in)
The TSeries is filtered and the result placed in a new TSeries. The resulting TSeries is left on the stack and must be copied to be made permanent. The filter status flag is set if there are insufficient history entries (less than the Filter order) or if the TSeries start time isn't contiguous with the previous data. The input samples are appended to the filter history as the filter response is calculated.
Returns:
A new TSeries containing the filter response to the input series.
Parameters:
in - Time series to be filtered.

void dataCheck(const TSeries& ts) const
Test whether the TSeries is valid as input data for the filter. a runtime_error exception is thrown in f the data are invalid.

Time getCurrentTime(void) const
Get the expected start time of the next TSeries to be filtered.
Returns:
true The current time.

int getLength(void) const throw()
Get the filter length. The filter state is not affected.
Returns:
The filter length (Order+1)

double getRate(void) const throw()
Get the sample rate. The filter state is not affected.
Returns:
The nominal sample rate in Hz.

Time getStartTime(void) const
Get the start time of this filter run. This is set by the first filter operation after the filter has been created or reset.
Returns:
true The start time.

bool getStat(void) const throw()
Tests whether the previous filter operation used valid history data. History data is considered to be valid if the history buffer is full and the start time of the input data is equal to the time stamp on the history data. The filter state is not affected.
Returns:
true if the filter history data was valid for the last operation.

bool inUse(void) const
Test the filter acitivity status.
Returns:
true if the filter is being used.

void dump(ostream& ostr) const throw()
All filter coefficients and history data are formatted and written to the specified ostream.
Parameters:
ostr - Output stream to receive the Filter info.

TSeries apply(const TSeries& in)
The TSeries is filtered and the result placed in a new TSeries. The resulting TSeries is left on the stack and must be copied to be made permanent. The filter status flag is set if there are insufficient history entries (less than the Filter order) or if the TSeries start time isn't contiguous with the previous data. The input samples are appended to the filter history as the filter response is calculated.
Returns:
A new TSeries containing the filter response to the input series.
Parameters:
in - Time series to be filtered.

TSeries& apply(const TSeries& in, TSeries& out) throw(invalid_argument)
The TSeries is filtered and the result stored in a specified output TSeries. The output TSeries must already exist. The filter status flag is set if there are insufficient history entries (less than the Filter order) or if the TSeries start time isn't contiguous with the previous data. The input samples are appended to the filter history as the filter response is calculated.
Returns:
reference to the TSeries containing the filter response.
Parameters:
in - Time series to be filtered.
out - Time series into which the filter response will be stored.

void apply(int N, const float* in, float* out)
An N-point float series is filtered from in and stored in out. in may overlap out. The input samples are appended to the filter history as the filter response is calculated.
Parameters:
N - Number of elements in the input series.
in - Float array containing the input series.
out - Float array to contain the filter response. the end of out may overlap the start of in.

void apply(int N, const fComplex* in, fComplex* out)
An N-point complex series is filtered from in and stored in out. in may overlap out. The input samples are appended to the filter history as the filter response is calculated.
Parameters:
N - Number of elements in the input series.
in - Float array containing the input series.
out - Float array to contain the filter response. the end of out may overlap the start of in.

void reset(void)
Set the filter length and coefficients. The filter history buffer is cleared.
Parameters:
N - Number of coefficients to set.
Coefs - A list of filter coefficients (filter impulse response).

FIRFilter& operator=(const FIRFilter& model) throw()
A filter is constructed with the same length, frequency and coefficients as the argument Filter. The history is zeroed.
Parameters:
model - Filter to be copied.

void setCoefs(int N, const double* Coefs) throw()
Set the filter length and coefficients. The filter history buffer is cleared.
Parameters:
N - Number of coefficients to set.
Coefs - A list of filter coefficients (filter impulse response).

void setHistory(int N, const float* Hist=0, Time t=Time(0)) throw()
The specified samples are copied to the Filter history vector. If the number of samples specified is greater than the filter size, only the last Norder samples are used. If the data vector argument is omitted the number of history terms is set as specified and any current data are prefixed with zeroes as needed to fill out the requested number of terms. The history time is optional and represents the time of the latest sample.
Parameters:
N - Number of history elements to preset.
Hist - Filter history vector.
t - Time of the last sample in the history list.

void setHistory(int N, const fComplex* Hist, Time t=Time(0)) throw()
The specified samples are copied to the Filter history vector. If the number of samples specified is greater than the filter size, only the last Norder samples are used. If the data vector argument is omitted the number of history terms is set as specified and any current data are prefixed with zeroes as needed to fill out the requested number of terms. The history time is optional and represents the time of the latest sample.
Parameters:
N - Number of history elements to preset.
Hist - Filter history vector.
t - Time of the last sample in the history list.

void setLength(int N) throw()
Set the filter length (order+1). The coefficients and history of the filter are cleared.
Parameters:
N - new filter length.

void setRate(double F) throw()
Set the filter sample Rate.
Parameters:
F - New sample frequency.

FSeries Xfer(float Fmin=0.0, float Fmax=0.0, float dF=1.0) const throw()
The transfer function of the filter in the specified frequency interval is calculated and returned as a complex frequency series.
Returns:
a complex FSeries containing the Filter response at each frequency step.
Parameters:
Fmin - Minimum frequency at which to sample the transfer function.
Fmax - Maximum frequency at which to sample the transfer function.
dF - Frequency step.


This class has no child classes.
Author:
John G. Zweizig
Version:
1.1; Last modified: October 29, 1999

alphabetic index hierarchy of classes


generated by doc++