diff --git a/plugins/gain/src/lib.rs b/plugins/gain/src/lib.rs index 4fdda82d..8c1adbf2 100644 --- a/plugins/gain/src/lib.rs +++ b/plugins/gain/src/lib.rs @@ -57,7 +57,7 @@ impl Default for GainParams { Self { gain: FloatParam { value: 0.0, - smoothed: Smoother::new(SmoothingStyle::SmoothLinear(3.0)), + smoothed: Smoother::new(SmoothingStyle::Linear(3.0)), value_changed: None, // If, for instance, updating this parameter would require other parts of the // plugin's internal state to be updated other values to also be updated, then you diff --git a/plugins/sine/src/lib.rs b/plugins/sine/src/lib.rs index 8f23b6c2..317b2680 100644 --- a/plugins/sine/src/lib.rs +++ b/plugins/sine/src/lib.rs @@ -60,7 +60,7 @@ impl Default for SineParams { Self { gain: FloatParam { value: -10.0, - smoothed: Smoother::new(SmoothingStyle::SmoothLinear(3.0)), + smoothed: Smoother::new(SmoothingStyle::Linear(3.0)), range: Range::Linear { min: -30.0, max: 0.0, @@ -72,7 +72,7 @@ impl Default for SineParams { }, frequency: FloatParam { value: 420.0, - smoothed: Smoother::new(SmoothingStyle::SmoothLinear(10.0)), + smoothed: Smoother::new(SmoothingStyle::Linear(10.0)), range: Range::Skewed { min: 1.0, max: 20_000.0, diff --git a/src/param/smoothing.rs b/src/param/smoothing.rs index c431e1a7..489e3d7b 100644 --- a/src/param/smoothing.rs +++ b/src/param/smoothing.rs @@ -20,7 +20,7 @@ pub enum SmoothingStyle { /// available for the parameters. None, /// Smooth parameter changes so the . - SmoothLinear(f32), + Linear(f32), // TODO: Sample-accurate modes } @@ -79,13 +79,11 @@ impl Smoother { } else { self.steps_left = match self.style { SmoothingStyle::None => 1, - SmoothingStyle::SmoothLinear(time) => (sample_rate * time / 1000.0).round() as u32, + SmoothingStyle::Linear(time) => (sample_rate * time / 1000.0).round() as u32, }; self.step_size = match self.style { SmoothingStyle::None => 0.0, - SmoothingStyle::SmoothLinear(_) => { - (self.target - self.current) / self.steps_left as f32 - } + SmoothingStyle::Linear(_) => (self.target - self.current) / self.steps_left as f32, }; } } @@ -102,7 +100,7 @@ impl Smoother { } else { match &self.style { SmoothingStyle::None => self.current = self.target, - SmoothingStyle::SmoothLinear(_) => self.current += self.step_size, + SmoothingStyle::Linear(_) => self.current += self.step_size, }; } @@ -122,11 +120,11 @@ impl Smoother { } else { self.steps_left = match self.style { SmoothingStyle::None => 1, - SmoothingStyle::SmoothLinear(time) => (sample_rate * time / 1000.0).round() as u32, + SmoothingStyle::Linear(time) => (sample_rate * time / 1000.0).round() as u32, }; self.step_size = match self.style { SmoothingStyle::None => 0.0, - SmoothingStyle::SmoothLinear(_) => { + SmoothingStyle::Linear(_) => { (self.target as f32 - self.current) / self.steps_left as f32 } }; @@ -142,7 +140,7 @@ impl Smoother { } else { match &self.style { SmoothingStyle::None => self.current = self.target as f32, - SmoothingStyle::SmoothLinear(_) => self.current += self.step_size, + SmoothingStyle::Linear(_) => self.current += self.step_size, }; }