From c60a151ca5c725ccaac1be350a5998a6fbf444d2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 9 Nov 2024 23:42:16 +0100 Subject: [PATCH] Small optimization to LinearValueSmoother Signed-off-by: falkTX --- distrho/extra/ValueSmoother.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/distrho/extra/ValueSmoother.hpp b/distrho/extra/ValueSmoother.hpp index 6b78a086..75f3169e 100644 --- a/distrho/extra/ValueSmoother.hpp +++ b/distrho/extra/ValueSmoother.hpp @@ -180,20 +180,20 @@ public: inline float peek() const noexcept { const float dy = target - mem; - return mem + std::copysign(std::fmin(std::abs(dy), std::abs(step)), dy); + return mem + std::copysign(std::fmin(std::abs(dy), step), dy); } inline float next() noexcept { const float y0 = mem; const float dy = target - y0; - return (mem = y0 + std::copysign(std::fmin(std::abs(dy), std::abs(step)), dy)); + return (mem = y0 + std::copysign(std::fmin(std::abs(dy), step), dy)); } private: void updateStep() noexcept { - step = (target - mem) / (tau * sampleRate); + step = std::abs(target - mem) / (tau * sampleRate); } };