Browse Source

Fix documentation for RCFilter::setCutoff to dodge math error. Add setCutoffFreq with the correct frequency relation.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
e667c7da21
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      include/dsp/filter.hpp

+ 7
- 2
include/dsp/filter.hpp View File

@@ -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;


Loading…
Cancel
Save