From e667c7da218964ca14d83538d62bb7648f38f995 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 5 Jun 2019 07:45:51 -0400 Subject: [PATCH] Fix documentation for RCFilter::setCutoff to dodge math error. Add setCutoffFreq with the correct frequency relation. --- include/dsp/filter.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/dsp/filter.hpp b/include/dsp/filter.hpp index df72e0d4..67fec706 100644 --- a/include/dsp/filter.hpp +++ b/include/dsp/filter.hpp @@ -25,12 +25,17 @@ struct TRCFilter { ystate[0] = 0.f; } - /** Sets the cutoff frequency. - `r` is the ratio between the cutoff frequency and sample rate, i.e. r = f_c / f_s + /** Sets the cutoff angular frequency in radians. */ void setCutoff(T r) { c = 2.f / r; } + /** Sets the cutoff frequency. + `f` is the ratio between the cutoff frequency and sample rate, i.e. f = f_c / f_s + */ + void setCutoffFreq(T f) { + setCutoff(2.f * M_PI * f); + } void process(T x) { T y = (x + xstate[0] - ystate[0] * (1 - c)) / (1 + c); xstate[0] = x;