refactor: move iir_filter to separate compilation unit

This commit is contained in:
2026-03-02 17:23:14 +01:00
parent 7de913f19c
commit 6ff7db4d93
9 changed files with 103 additions and 70 deletions

View File

@@ -0,0 +1,46 @@
//
// Created by david on 02.03.2026.
//
#ifndef PASADASUPERPROJECT_IIR_FILTER_H
#define PASADASUPERPROJECT_IIR_FILTER_H
#include <utility>
#include <vector>
#include <stdexcept>
/** Shift register implemented as a circular buffer. */
class Buf {
protected:
std::vector<double> data;
size_t size;
size_t n;
public:
Buf(size_t N);
void push(double val);
};
/** Running filter base. */
class Filt : Buf {
protected:
std::vector<double> taps;
size_t shift;
size_t offset;
public:
Filt(size_t N, size_t shift, size_t offset, std::vector<double> taps);
double filter(double val);
double peek();
void push(double val);
};
/** Running IIR filter. */
class IirFilter {
protected:
Filt y;
Filt x;
public:
IirFilter(std::vector<double> b, std::vector<double> a);
double filter(double val);
};
#endif //PASADASUPERPROJECT_IIR_FILTER_H