#include <Filter.h>
Public Member Functions | |
Filter (void) | |
Construct a filter with an all-pass unity gain response. | |
template<typename IterT1 , typename IterT2 > | |
Filter (IterT1 ffwdbegin, IterT1 ffwdend, IterT2 fbackbegin, IterT2 fbackend, double gain=1.) | |
Filter (const Filter &other) | |
Filter & | operator= (const Filter &rhs) |
~Filter (void) | |
double | apply (double input) |
double | operator() (double input) |
std::vector< double > | numerator (void) |
const std::vector< double > | numerator (void) const |
std::vector< double > | denominator (void) |
const std::vector< double > | denominator (void) const |
void | clear (void) |
Clear the filter state. |
Filter is an Direct Form II realization of a filter specified by its difference equation coefficients and (optionally) gain, applied to the filter output (defaults to 1.). Coefficients are specified and stored in order of increasing delay.
Implements the rational transfer function
-1 -nb b[0] + b[1]z + ... + b[nb] z Y(z) = G ---------------------------------- X(z) -1 -na a[0] + a[1]z + ... + a[na] z
where b[k] are the feed forward coefficients, and a[k] are the feedback coefficients. If a[0] is not 1, then both a and b are normalized by a[0]. G is the additional filter gain, and is unity if unspecified.
Filter is implemented using a std::deque to store the filter state, and relies on the efficiency of that class. If deque is not implemented using some sort of circular buffer (as it should be -- deque is guaranteed to be efficient for repeated insertion and removal at both ends), then this filter class will be slow.
Loris::Filter::Filter | ( | IterT1 | ffwdbegin, | |
IterT1 | ffwdend, | |||
IterT2 | fbackbegin, | |||
IterT2 | fbackend, | |||
double | gain = 1. | |||
) | [inline] |
Initialize a Filter having the specified coefficients, and order equal to the larger of the two coefficient ranges. Coefficients in the sequences are stored in increasing order (lowest order coefficient first).
If template members are allowed, then the coefficients can be stored in any kind of iterator range, otherwise, they must be in an array of doubles.
ffwdbegin | is the beginning of a sequence of feed-forward coefficients | |
ffwdend | is the end of a sequence of feed-forward coefficients | |
fbackbegin | is the beginning of a sequence of feedback coefficients | |
fbackend | is the end of a sequence of feedback coefficients | |
gain | is an optional gain scale applied to the filtered signal |
Loris::Filter::Filter | ( | const Filter & | other | ) |
Make a copy of another digital filter. Do not copy the filter state (delay line).
Loris::Filter::~Filter | ( | void | ) |
Destructor is virtual to enable subclassing. Subclasses may specialize construction, and may add functionality, but for efficiency, the filtering operation is non-virtual.
double Loris::Filter::apply | ( | double | input | ) |
Compute a filtered sample from the next input sample.
input | is the next input sample |
const std::vector< double > Loris::Filter::denominator | ( | void | ) | const |
Provide access to the denominator (feedback) coefficients of this filter. The coefficients are stored in order of increasing delay (lowest order coefficient first).
std::vector< double > Loris::Filter::denominator | ( | void | ) |
Provide access to the denominator (feedback) coefficients of this filter. The coefficients are stored in order of increasing delay (lowest order coefficient first).
const std::vector< double > Loris::Filter::numerator | ( | void | ) | const |
Provide access to the numerator (feed-forward) coefficients of this filter. The coefficients are stored in order of increasing delay (lowest order coefficient first).
std::vector< double > Loris::Filter::numerator | ( | void | ) |
Provide access to the numerator (feed-forward) coefficients of this filter. The coefficients are stored in order of increasing delay (lowest order coefficient first).
double Loris::Filter::operator() | ( | double | input | ) | [inline] |
Function call operator, same as sample().
Make a copy of another digital filter. Do not copy the filter state (delay line).