refactored FIR filters

- real and complex variant
adjusted StepDetection2
This commit is contained in:
k-a-z-u
2018-07-03 10:56:30 +02:00
parent ae3b95cb0e
commit 039f9c4cee
6 changed files with 285 additions and 9 deletions

View File

@@ -19,7 +19,7 @@
#include "../../Assertions.h"
#include "../../math/MovingAverageTS.h"
#include "../../math/dsp/FIRComplex.h"
//#include "../../math/dsp/fir/RComplex.h"
/**

View File

@@ -22,7 +22,8 @@
#endif
#include "../../Assertions.h"
#include "../../math/dsp/FIRComplex.h"
#include "../../math/dsp/fir/Real.h"
#include "../../math/dsp/fir/RealFactory.h"
#include "../../math/FixedFrequencyInterpolator.h"
#include "../../math/LocalMaxima.h"
#include "../../math/MovingAverageTS.h"
@@ -41,7 +42,7 @@ class StepDetection2 {
private:
FixedFrequencyInterpolator<AccelerometerData> interpol;
FIRComplex fir;
FIR::Real::Filter fir;
LocalMaxima locMax;
// longterm average to center around zero
@@ -68,12 +69,16 @@ private:
public:
/** ctor */
StepDetection2() : interpol(Timestamp::fromMS(every_ms)), fir(sRate_hz), locMax(8) {
StepDetection2() : interpol(Timestamp::fromMS(every_ms)), locMax(8) {
//fir.lowPass(0.66, 40); // allow deviation of +/- 0.66Hz
//fir.shiftBy(2.00); // typical step freq ~2Hz
fir.lowPass(3.5, 25); // everything up to 3 HZ
//fir.lowPass(3.5, 25); // everything up to 3 HZ
FIR::Real::Factory fac(sRate_hz);
fir.setKernel(fac.getBandpass(0.66, 2.0, 40));
#ifdef WITH_DEBUG_PLOT
gp << "set autoscale xfix\n";
@@ -104,10 +109,13 @@ public:
avg.add(ts, mag);
const float mag0 = mag - avg.get();
const std::complex<float> c = fir.append(mag0);
const float real = c.real();
if (real != real) {return;}
const float fMag = real;
//const std::complex<float> c = fir.append(mag0);
//const float real = c.real();
//if (real != real) {return;}
//const float fMag = real;
const float f = fir.append(mag0);
if (f != f) {return;}
const float fMag = f;
const bool isMax = locMax.add(fMag);