Overload List
| # | Signature | Description |
|---|---|---|
| 1 | void IirFilter(TVec *Src, TVec *Dst, TIirState &IIRState); | Filter data with an IIR filter. |
| 2 | void IirFilter(TVec *Data, TIirState &IIRState, bool LinearPhase = false); | Filter data with an IIR filter. |
| 3 | void IirFilter(TVec *Data, TVec *Num, TVec *Den, bool LinearPhase = false); | Filter Data and place the result back in Data. |
| 4 | void IirFilter(double Src, double &Dst, TIirState &IIRState); | Filter data with an IIR filter. |
| 5 | void IirFilter(float Src, float &Dst, TIirState &IIRState); | |
| 6 | void IirFilter(const TCplx &Src, TCplx &Dst, TIirState &IIRState); | Filter data with an IIR filter. |
| 7 | void IirFilter(const TSCplx &Src, TSCplx &Dst, TIirState &IIRState); |
Overload 1: void IirFilter(TVec *Src, TVec *Dst, TIirState &IIRState);
Filter data with an IIR filter.
Filter data in Src and place the result in Dst. IirState must be initialized with a call to IirInit.
Note
Use this routine for filtering of streaming data.
#include "MtxExpr.h"
#include "Units.IIrFilters.h"
#include "Units.SignalUtils.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Signal;
using namespace Dew::Signal::Units::IIRFilters;
using namespace Dew::Signal::Units::SignalUtils;
void Example()
{
Vector b, c, Response, Response1, num, den;
TIirState State;
int n, i;
Tone(b, 300, 6.0/300, 0, 1);
// Alternative: try gaussian noise
// b = RandGauss(300, TMtxFloatPrecision::mvDouble);
c.Size(b);
ChebyshevIFilter(6, 0.2, DewArray<double>{0.6}, TFilterType::ftLowpass, false, num, den);
State = TIirState();
IirInit(num, den, State);
//Alternative 1, IIR streaming
n = 10;
int bLength = b.Length;
for (i = 0; i <= (bLength / n) - 1; i++)
{
b.SetSubRange(i*n, n);
c.SetSubRange(i*n, n);
IirFilter(b, c, State);
}
//Alternative 2 single block filter (does not require TIirState)
// c.Copy(b);
// IirFilter(c, num, den, true);
//Alternative 3 single block
// c.Copy(b);
// IirFilter(c, State);
c.SetFullRange();
b.SetFullRange();
FrequencyResponse(b, nullptr, Response, 8, true, TSignalWindowType::wtHanning);
FrequencyResponse(c, nullptr, Response1, 8, true, TSignalWindowType::wtHanning);
IirFree(State);
}
Overload 2: void IirFilter(TVec *Data, TIirState &IIRState, bool LinearPhase = false);
Filter data with an IIR filter.
Filter Data and place the result back in Data. Use this routine for filtering of non-consecutive blocks of data. Set LinearPhase to True to double filter attenuation and ensure no phase distortion and no phase delay.
Overload 3: void IirFilter(TVec *Data, TVec *Num, TVec *Den, bool LinearPhase = false);
Filter Data and place the result back in Data.
The Iir filter is defined with a transfer function. Num is numerator and Den is denominator. Set LinearPhase to True to double filter attenuation and ensure no phase distortion and no phase delay (except for the initial transition regions).
#include "MtxExpr.h"
#include "Units.IIrFilters.h"
#include "Units.SignalUtils.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Signal;
using namespace Dew::Signal::Units::IIRFilters;
using namespace Dew::Signal::Units::SignalUtils;
void Example()
{
Vector b(0);
Vector c(0);
Vector num(0);
Vector den(0);
Vector Response1(0);
Vector Response2(0);
TIirState state;
int n;
int i;
Tone(b, 300, 6.0/300, 0, 1, false);
// Alternative: try gaussian noise
// b = RandGauss(300, TMtxFloatPrecision::mvDouble);
c.Size(b);
ChebyshevIFilter(6, 0.2, DewArray<double>{0.6}, TFilterType::ftLowpass, false, num, den, TIirFrequencyTransform::ftStateSpaceAnalog);
IirInit(num, den, state, false);
//Alternative 1, IIR streaming
n = 10;
int bLength = b.Length; //to prevente reevaluaton inside "for"
for (i = 0; i < (bLength/n); i++)
{
b.SetSubRange(i*n, n);
c.SetSubRange(i*n, n);
IirFilter(b, c, state);
}
IirFree(state);
//Alternative 2 single block filter (does not require TIirState)
// c.Copy(b);
// IirFilter(c, num, den, true);
//Alternative 3 single block
// c.Copy(b);
// IirFilter(c, state);
c.SetFullRange();
b.SetFullRange();
FrequencyResponse(c, nullptr, Response1, 1, true, TSignalWindowType::wtHanning, 0);
FrequencyResponse(b, nullptr, Response2, 1, true, TSignalWindowType::wtHanning, 0);
}
Overload 4: void IirFilter(double Src, double &Dst, TIirState &IIRState);
Filter data with an IIR filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | double | |
| 2 | Dst | double & | |
| 3 | IIRState | TIirState & |
Filters sample Src and places real valued output of the filter in Dst.
Overload 5: void IirFilter(float Src, float &Dst, TIirState &IIRState);
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | float | |
| 2 | Dst | float & | |
| 3 | IIRState | TIirState & |
Overload 6: void IirFilter(const TCplx &Src, TCplx &Dst, TIirState &IIRState);
Filter data with an IIR filter.
Filters sample Src and places complex output of the filter in Dst.