From 1d5ea0599ea257b467dcc13bb51595e3eca13842 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sun, 6 Jun 2021 13:33:41 +0200 Subject: [PATCH] round instead of flooring cents --- src/dsp/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dsp/mod.rs b/src/dsp/mod.rs index a750190..11407c6 100644 --- a/src/dsp/mod.rs +++ b/src/dsp/mod.rs @@ -257,9 +257,9 @@ macro_rules! n_det { ($x: expr) => { $x / 120.0 } } macro_rules! d_det { ($x: expr) => { $x * 120.0 } } macro_rules! r_det { ($x: expr, $coarse: expr) => { if $coarse { - n_det!((d_det!($x)).floor()) + n_det!((d_det!($x)).round()) } else { - n_det!((d_det!($x) * 10.0).floor() / 10.0) + n_det!((d_det!($x) * 10.0).round() / 10.0) } } } @@ -285,7 +285,7 @@ macro_rules! f_det { ($formatter: expr, $v: expr, $denorm_v: expr) => { { let sign = if $denorm_v < 0.0 { -1.0 } else { 1.0 }; let semitones = $denorm_v.floor().abs(); - let cents = ($denorm_v.fract() * 100.0).floor().abs(); + let cents = ($denorm_v.fract() * 100.0).round().abs(); if (cents > 1.0) { write!($formatter, "{:2.0}s {:3.0}c", sign * semitones, cents)