From 5b2f8a417b2ddd512fc68ef1c7a8ab7c9d511f82 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 21 Mar 2022 14:44:26 +0100 Subject: [PATCH] Use the f32_hz_then_khz formatter --- plugins/diopser/src/lib.rs | 5 +++-- plugins/examples/sine/src/lib.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/diopser/src/lib.rs b/plugins/diopser/src/lib.rs index 1f699890..e18ca0e9 100644 --- a/plugins/diopser/src/lib.rs +++ b/plugins/diopser/src/lib.rs @@ -170,8 +170,9 @@ impl DiopserParams { ) // This needs quite a bit of smoothing to avoid artifacts .with_smoother(SmoothingStyle::Logarithmic(100.0)) - .with_unit(" Hz") - .with_value_to_string(formatters::f32_rounded(0)), + // This includes the unit + .with_value_to_string(formatters::f32_hz_then_khz(0)) + .with_string_to_value(formatters::from_f32_hz_then_khz()), filter_resonance: FloatParam::new( "Filter Resonance", // The actual default neutral Q-value would be `sqrt(2) / 2`, but this value diff --git a/plugins/examples/sine/src/lib.rs b/plugins/examples/sine/src/lib.rs index aab39eba..3414dfe1 100644 --- a/plugins/examples/sine/src/lib.rs +++ b/plugins/examples/sine/src/lib.rs @@ -69,10 +69,10 @@ impl Default for SineParams { }, ) .with_smoother(SmoothingStyle::Linear(10.0)) - .with_unit(" Hz") // We purposely don't specify a step size here, but the parameter should still be - // displaeyd as rounded - .with_value_to_string(formatters::f32_rounded(0)), + // displayed as if it were rounded. This formatter also includes the unit. + .with_value_to_string(formatters::f32_hz_then_khz(0)) + .with_string_to_value(formatters::from_f32_hz_then_khz()), use_midi: BoolParam::new("Use MIDI", false), } }