#include <Filter.h>
Public Member Functions | |
Filter (int channelCount=1) | |
void | process (const MatrixXR &samples, MatrixXR *filtered) |
void | a (MatrixXR *a) const |
void | setA (const MatrixXR &a, bool callSetup=true) |
void | b (MatrixXR *b) const |
void | setB (const MatrixXR &b, bool callSetup=true) |
int | channelCount () const |
void | setChannelCount (int count, bool callSetup=true) |
int | length () const |
This class represents an object to apply one or several IIR filters. The coefficients must be manually set by the user. To create and use some special parametrized filters such as Low Pass, High Pass, Band Pass and Band Stop filters refer to IIRFilter.
For Complex coefficient filters, refer to FilterComplex.
This filter implementation allows single and multiple channel filtering. The number of channels is specified using the setChannelCount(). The a and b coefficients of the filter are specified by two matrices of Real values. The rows of the matrix are the time indices of the filter and the columns (if more than one) are the channels.
Three different situations are possible, depending on the number of columns in the coefficients matrices and in the input matrix:
Note that in all cases the number of columns in a and b coefficients matrices must be the same. Note that the channel count determines the number of output channels in any situation and is therefore must be equal to the maximum number of channels between input and coefficient matrices.
Filter | ( | int | channelCount = 1 |
) |
Constructs a band pass filter object with the given channelCount, b, and a coefficients given.
References setA(), setB(), and setChannelCount().
void process | ( | const MatrixXR & | samples, | |
MatrixXR * | filtered | |||
) |
Performs a filtering of each of the columns of samples. Puts the resulting filtered in the columns of filtered.
samples | matrix of Real values. A column represents a channel and a row represents a time index. | |
filtered | pointer to a matrix of Real values for the output. The matrix should have the same number of rows and columns as samples. |
Referenced by LPC::process(), and BandFilter::process().
void a | ( | MatrixXR * | a | ) | const |
Returns the a coefficients of the filter
Both the b and a coefficients matrices are normalized by the first row of the a coefficients matrix.
Note that if the first row of the a coefficients matrix has elements to zero, some of the filtered samples will result in NaN.
Note that the number of columns in a and b must be the same, and that it must be equal to 1 or Filter::channelCount.
By default it is a single element matrix of value 1.0.
Referenced by BandFilter::a().
void setA | ( | const MatrixXR & | a, | |
bool | callSetup = true | |||
) |
Specifies the a coefficients of the filter
Both the b and a coefficients matrices are normalized by the first row of the a coefficients matrix.
Note that if the first row of the a coefficients matrix has elements to zero, some of the filtered samples will result in NaN.
Note that the number of columns in a and b must be the same, and that it must be equal to 1 or Filter::channelCount.
Referenced by Filter().
void b | ( | MatrixXR * | b | ) | const |
Returns the b coefficients of the filter
Both the b and a coefficients matrices are normalized by the first row of the a coefficients matrix.
Note that if the first row of the a coefficients matrix has elements to zero, some of the filtered samples will result in NaN.
Note that the number of columns in a and b must be the same, and that it must be equal to 1 or the channel count.
By default it is a single element matrix of value 1.0.
Referenced by BandFilter::b().
void setB | ( | const MatrixXR & | b, | |
bool | callSetup = true | |||
) |
Specifies the b coefficients of the filter
Both the b and a coefficients matrices are normalized by the first row of the a coefficients matrix.
Note that if the first row of the a coefficients matrix has elements to zero, some of the filtered samples will result in NaN.
Note that the number of columns in a and b must be the same, and that it must be equal to 1 or the channel count.
Referenced by Filter().
int channelCount | ( | ) | const |
Returns the number of output channles of the filter
Note that the number of channels must be equal to the number of columns in a and b or to the number of columns in the input matrix.
By default it is 1.
void setChannelCount | ( | int | count, | |
bool | callSetup = true | |||
) |
Specifies the number of output channles of the filter
Note that the number of channels must be equal to the number of columns in a and b or to the number of columns in the input matrix.
Referenced by Filter().
int length | ( | ) | const |
Returns the length of the filter, which is the maximum number of rows between the a and b coefficients matrices.