From 84d347c7ab911da7c46a0bc09d0fc2e382c38611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 10 Nov 2023 17:11:22 +0100 Subject: [PATCH] Fix inaccurate envelope point value rounding Round to nearest integer instead of truncating in `f2fx` to ensure correct round-trip with `fx2f`. --- src/base/math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/math.h b/src/base/math.h index 1a6692ea076..b4b553bbc4e 100644 --- a/src/base/math.h +++ b/src/base/math.h @@ -66,7 +66,7 @@ constexpr int fxpscale = 1 << 10; // float to fixed constexpr inline int f2fx(float v) { - return (int)(v * fxpscale); + return round_to_int(v * fxpscale); } constexpr inline float fx2f(int v) {