From 82ce34dea3b9230e42fe2fe9e2562d1f2b85d699 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Fri, 7 May 2021 17:18:06 +0200 Subject: [PATCH] use well known order of lerp arguments --- amd.hh | 2 +- ema.hh | 4 ++-- utils.hh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/amd.hh b/amd.hh index 1048686..c310ffa 100644 --- a/amd.hh +++ b/amd.hh @@ -32,7 +32,7 @@ public: value_type operator()(complex_type input) { value_type amp = abs(input); - avg = lerp(amp < avg ? dec : att, avg, amp); + avg = lerp(avg, amp, amp < avg ? dec : att); avg = min(max(avg, lo), hi); amp /= avg; return (amp * (value_type(1)+idx) - value_type(1)) / idx; diff --git a/ema.hh b/ema.hh index 4a23a4d..fd86ddd 100644 --- a/ema.hh +++ b/ema.hh @@ -35,7 +35,7 @@ public: } TYPE operator()(TYPE input) { - return prev = lerp(alpha, prev, input); + return prev = lerp(prev, input, alpha); } }; @@ -83,7 +83,7 @@ public: TYPE operator()(TYPE input) { for (int i = 0; i < ORDER; ++i) - prev[i] = input = lerp(alpha, prev[i], input); + prev[i] = input = lerp(prev[i], input, alpha); return input; } }; diff --git a/utils.hh b/utils.hh index 8a004e5..4ba2d79 100644 --- a/utils.hh +++ b/utils.hh @@ -16,8 +16,8 @@ int signum(TYPE v) return (v > TYPE(0)) - (v < TYPE(0)); } -template -AB lerp(X x, AB a, AB b) +template +AB lerp(AB a, AB b, X x) { return (X(1) - x) * a + x * b; }