diff --git a/nih_plug/src/params.rs b/nih_plug/src/params.rs index 11e29618..3558c94a 100644 --- a/nih_plug/src/params.rs +++ b/nih_plug/src/params.rs @@ -140,7 +140,7 @@ impl NormalizebleRange for Range { fn unnormalize(&self, normalized: f32) -> i32 { match &self { - Range::Linear { min, max } => (normalized * (max - min) as f32) as i32 + min, + Range::Linear { min, max } => (normalized * (max - min) as f32).round() as i32 + min, } } } @@ -263,4 +263,10 @@ mod tests { let range = make_linear_int_range(); assert_eq!(range.unnormalize(0.75), 5); } + + #[test] + fn range_unnormalize_linear_int_rounding() { + let range = make_linear_int_range(); + assert_eq!(range.unnormalize(0.73), 5); + } }