2018-12-21 00:01:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <nall/dsp/dsp.hpp>
|
|
|
|
|
|
|
|
//DC offset removal IIR filter
|
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
namespace nall::DSP::IIR {
|
2018-12-21 00:01:14 +00:00
|
|
|
|
|
|
|
struct DCRemoval {
|
|
|
|
inline auto reset() -> void;
|
|
|
|
inline auto process(double in) -> double; //normalized sample (-1.0 to +1.0)
|
|
|
|
|
|
|
|
private:
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto DCRemoval::reset() -> void {
|
|
|
|
x = 0.0;
|
|
|
|
y = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto DCRemoval::process(double in) -> double {
|
|
|
|
x = 0.999 * x + in - y;
|
|
|
|
y = in;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
}
|