zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 268effbe5c1a8dae5c6c6e134b4d953d120ceb6b
parent a74f314bbf5aa41c9350361a396f30a5dae46c10
Author: Friedolino <mkirchn@freenet.de>
Date:   Fri,  2 Oct 2020 12:56:16 +0200

make lfo biquad independet to sampling frequency

Diffstat:
Msrc/Synth/LFO.cpp | 8++++++--
Msrc/Synth/LFO.h | 2+-
2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/Synth/LFO.cpp b/src/Synth/LFO.cpp @@ -21,6 +21,8 @@ namespace zyn { +#define LIMIT(x,lu, ll) (x>lu ? lu : (x<ll ? ll : x) ) + LFO::LFO(const LFOParams &lfopars, float basefreq, const AbsTime &t, WatchManager *m, const char *watch_prefix) :first_half(-1), @@ -133,8 +135,10 @@ float LFO::biquad(float input) if (cutoff != 127) // at cutoff 127 we bypass filter, no coeffs needed { // calculate biquad coefficients - Fc = powf(cutoff + 7.0f, 2.0f)/ 45056.0f; - K = tan(PI * Fc); + FcAbs = (cutoff + 7.0f)*(cutoff + 7.0f)/ 450.56f; // max value < 40 + K = tan(PI * LIMIT(FcAbs * dt_,0.4,0.001)); // FcRel * dt_ max 40 * 0.01 = 0.4, + // LIMIT in case of LFO sampling frequency lower than 100 Hz + norm = 1 / (1 + K / 0.7071f + K * K); a0 = K * K * norm; a1 = 2 * a0; diff --git a/src/Synth/LFO.h b/src/Synth/LFO.h @@ -69,7 +69,7 @@ class LFO const LFOParams &lfopars_; const float basefreq_; - float Fc, K, norm; + float FcAbs, K, norm; //biquad coefficients for lp filtering in noise-LFO float a0 = 0.0007508914611009499;