Skip to content

Commit

Permalink
Fix inaccurate envelope point value rounding
Browse files Browse the repository at this point in the history
Round to nearest integer instead of truncating in `f2fx` to ensure correct round-trip with `fx2f`.
  • Loading branch information
Robyt3 committed Nov 10, 2023
1 parent fa8640b commit 84d347c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/base/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 84d347c

Please sign in to comment.