BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit 2493251e26b5c68c036d56f345500fbd0181fb83
parent 1cdca5630f0daa24e63ba80edd733c6545021e0b
Author: Matt Demanett <matt@demanett.net>
Date:   Mon, 17 Feb 2020 12:25:09 -0500

DC blocker dsp.

Diffstat:
Msrc/Test.cpp | 6++++++
Msrc/Test.hpp | 7++++++-
Msrc/dsp/filter.cpp | 8++++++++
Msrc/dsp/filter.hpp | 7+++++++
4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/Test.cpp b/src/Test.cpp @@ -445,6 +445,12 @@ void Test::processChannel(const ProcessArgs& args, int _c) { _walk2.setParams(APP->engine->getSampleRate(), change); outputs[OUT_OUTPUT].setVoltage(_walk1.next()); outputs[OUT2_OUTPUT].setVoltage(_walk2.next()); + +#elif DCBLOCKER + float in = inputs[IN_INPUT].getVoltage(); + outputs[OUT_OUTPUT].setVoltage(_filter.next(in)); + outputs[OUT2_OUTPUT].setVoltage(in); + #endif } diff --git a/src/Test.hpp b/src/Test.hpp @@ -28,7 +28,8 @@ extern Model* modelTest; // #define RAVG 1 // #define SATURATOR 1 // #define BROWNIAN 1 -#define RANDOMWALK 1 +// #define RANDOMWALK 1 +#define DCBLOCKER 1 #include "pitch.hpp" #ifdef LPF @@ -92,6 +93,8 @@ extern Model* modelTest; #include "dsp/noise.hpp" #elif RANDOMWALK #include "dsp/noise.hpp" +#elif DCBLOCKER +#include "dsp/filter.hpp" #else #error what #endif @@ -227,6 +230,8 @@ struct Test : BGModule { #elif RANDOMWALK RandomWalk _walk1; RandomWalk _walk2; +#elif DCBLOCKER + DCBlocker _filter; #endif Test() diff --git a/src/dsp/filter.cpp b/src/dsp/filter.cpp @@ -71,6 +71,14 @@ void LowPassFilter::setParams(float sampleRate, float cutoff, float q) { } +float DCBlocker::next(float sample) { + const float r = 0.999f; + _lastOut = sample - _lastIn + r * _lastOut; + _lastIn = sample; + return _lastOut; +} + + // Adapted from Smith 1997, "The Scientist and Engineer's Guide to DSP" void MultipoleFilter::setParams( Type type, diff --git a/src/dsp/filter.hpp b/src/dsp/filter.hpp @@ -98,6 +98,13 @@ struct LowPassFilter : Filter { } }; +struct DCBlocker : Filter { + float _lastIn = 0.0f; + float _lastOut = 0.0f; + + float next(float sample) override; +}; + struct MultipoleFilter : Filter { enum Type { LP_TYPE,