Overload List
| # | Signature | Description |
|---|---|---|
| 1 | void FirFilter(TVec *Src, TVec *Dst, TFirState &FIRState); | Filter data with a FIR filter. |
| 2 | void FirFilter(const double Src, double &Dst, TFirState &FIRState); | Filter data with a FIR filter. |
| 3 | void FirFilter(const TCplx &Src, TCplx &Dst, TFirState &FIRState); | Filter data with a FIR filter. |
| 4 | void FirFilter(TVec *Data, TVec *FirTaps, int UpSample = 1, int DownSample = 1); | Filter Data with a FIR filter and place the result back in the Data. |
Overload 1: void FirFilter(TVec *Src, TVec *Dst, TFirState &FIRState);
Filter data with a FIR filter.
Remarks:
Filter data in Src and place the result in Dst. FirState must be initialized with a call to FirInit. This version of FirFilter routine can filter streaming blocks of data.
Examples
#include "MtxExpr.h"
#include "Units.OptimalFIR.h"
#include "Units.SignalUtils.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Signal;
using namespace Dew::Signal::Units::OptimalFir;
using namespace Dew::Signal::Units::SignalUtils;
void Example()
{
Vector b, c, Response, Response1, H;
TFirState State;
int n, i;
double FS;
FS = 2;
Tone(b, 300, 6.0/300, 0, 1);
// Alternative: try gaussian noise
// b = RandGauss(300, TMtxFloatPrecision::mvDouble);
c.Size(b);
RemezImpulse(H, DewArray<double>{0.5, 0.7}, 0.001, TFilterType::ftLowpass, 1, FS);
State = TFirState();
FirInit(H, State);
//Alternative 1, FIR 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);
FirFilter(b, c, State);
}
//Alternative 2 single block filter (does not require TIirState)
// c.Copy(b);
// FirFilter(c, H);
//Alternative 3 single block
// FirFilter(b, c, State);
c.SetFullRange();
b.SetFullRange();
FrequencyResponse(b, nullptr, Response, 8, true, TSignalWindowType::wtHanning);
FrequencyResponse(c, nullptr, Response1, 8, true, TSignalWindowType::wtHanning);
FirFree(State);
}
Declared in Dew::Signal::Units::SignalUtils · Dew.Signal/Units.SignalUtils.h · Cross-compiler
Overload 2: void FirFilter(const double Src, double &Dst, TFirState &FIRState);
Filter data with a FIR filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | const double | |
| 2 | Dst | double & | |
| 3 | FIRState | TFirState & |
Remarks:
Filter real Src sample and place the filtered result in Dst sample.
Declared in Dew::Signal::Units::SignalUtils · Dew.Signal/Units.SignalUtils.h · Cross-compiler
Overload 3: void FirFilter(const TCplx &Src, TCplx &Dst, TFirState &FIRState);
Filter data with a FIR filter.
Remarks:
Filter real TCplx sample and place the filtered result in Dst sample.
Declared in Dew::Signal::Units::SignalUtils · Dew.Signal/Units.SignalUtils.h · Cross-compiler
Overload 4: void FirFilter(TVec *Data, TVec *FirTaps, int UpSample = 1, int DownSample = 1);
Filter Data with a FIR filter and place the result back in the Data.
Remarks:
This version of FirFilter can not be used to filter streaming data. The routine compensates for group delay and returns filtered data delayed by 0 (odd FIR length) or 0.5 samples (even FIR length).
Examples
#include "MtxExpr.h"
#include "Units.OptimalFIR.h"
#include "Units.SignalUtils.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Signal;
using namespace Dew::Signal::Units::OptimalFir;
using namespace Dew::Signal::Units::SignalUtils;
void Example()
{
Vector b(0);
Vector c(0);
Vector h(0);
Vector Response1(0);
Vector Response2(0);
TFirState state;
int n;
int i;
double FS = 2;
Tone(b, 300, 6.0/300, 0, 1, false);
// Alternative: try gaussian noise
// b = RandGauss(300, TMtxFloatPrecision::mvDouble);
c.Size(b);
RemezImpulse(h, DewArray<double>{0.5, 0.7}, 0.001, TFilterType::ftLowpass, 1, FS, false);
FirInit(h, state, 1, 0, 1, 0);
//Alternative 1, FIR 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);
FirFilter(b, c, state);
}
c.SetFullRange();
b.SetFullRange();
FirFree(state);
//Alternative 2 single block filter (does not require TFirState)
// c.Copy(b);
// FirFilter(c, h, 1, 1);
//Alternative 3 single block
// c.Copy(b);
// FirFilter(b, c, state);
FrequencyResponse(b, nullptr, Response1, 1, true, TSignalWindowType::wtHanning, 0);
FrequencyResponse(c, nullptr, Response2, 1, true, TSignalWindowType::wtHanning, 0);
}
See Also: SignalUtils::FirInit, SignalUtils::FirFilter
Declared in Dew::Signal::Units::SignalUtils · Dew.Signal/Units.SignalUtils.h · Cross-compiler