From cd0b870682522a970a45ffb5b3c6a52f2f240338 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 12 Feb 2022 19:56:37 +0100 Subject: [PATCH] Directly pass a style to .with_smoother() --- plugins/examples/gain-gui/src/lib.rs | 2 +- plugins/examples/sine/src/lib.rs | 4 ++-- src/param.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/examples/gain-gui/src/lib.rs b/plugins/examples/gain-gui/src/lib.rs index 39218cdb..56177893 100644 --- a/plugins/examples/gain-gui/src/lib.rs +++ b/plugins/examples/gain-gui/src/lib.rs @@ -59,7 +59,7 @@ impl Default for GainParams { max: 30.0, }, ) - .with_smoother(Smoother::new(SmoothingStyle::Linear(50.0))) + .with_smoother(SmoothingStyle::Linear(50.0)) .with_unit(" dB") .with_value_to_string(formatters::f32_rounded(2)), some_int: IntParam::new( diff --git a/plugins/examples/sine/src/lib.rs b/plugins/examples/sine/src/lib.rs index 3c4c18ae..7d49fcf0 100644 --- a/plugins/examples/sine/src/lib.rs +++ b/plugins/examples/sine/src/lib.rs @@ -66,7 +66,7 @@ impl Default for SineParams { max: 0.0, }, ) - .with_smoother(Smoother::new(SmoothingStyle::Linear(3.0))) + .with_smoother(SmoothingStyle::Linear(3.0)) .with_unit(" dB") .with_value_to_string(formatters::f32_rounded(2)), frequency: FloatParam::new( @@ -78,7 +78,7 @@ impl Default for SineParams { factor: Range::skew_factor(-2.0), }, ) - .with_smoother(Smoother::new(SmoothingStyle::Linear(10.0))) + .with_smoother(SmoothingStyle::Linear(10.0)) .with_unit(" Hz") .with_value_to_string(formatters::f32_rounded(0)), use_midi: BoolParam::new("Use MIDI", false), diff --git a/src/param.rs b/src/param.rs index acf22d61..612cb500 100644 --- a/src/param.rs +++ b/src/param.rs @@ -6,7 +6,7 @@ use std::fmt::Display; use std::sync::Arc; use self::range::{NormalizebleRange, Range}; -use self::smoothing::Smoother; +use self::smoothing::{Smoother, SmoothingStyle}; pub mod internals; pub mod range; @@ -377,8 +377,8 @@ where /// is the parameter's new value. This should not do anything expensive as it may be called /// multiple times in rapid succession, and it can be run from both the GUI and the audio /// thread. - pub fn with_smoother(mut self, smoother: Smoother) -> Self { - self.smoothed = smoother; + pub fn with_smoother(mut self, style: SmoothingStyle) -> Self { + self.smoothed = Smoother::new(style); self }