1
0
Fork 0

Rename SmoothLinear to Linear

We'll rethink this when we get to sample accurate automation.
This commit is contained in:
Robbert van der Helm 2022-02-02 22:00:00 +01:00
parent 0ecec104fb
commit da291175d1
3 changed files with 10 additions and 12 deletions

View file

@ -57,7 +57,7 @@ impl Default for GainParams {
Self { Self {
gain: FloatParam { gain: FloatParam {
value: 0.0, value: 0.0,
smoothed: Smoother::new(SmoothingStyle::SmoothLinear(3.0)), smoothed: Smoother::new(SmoothingStyle::Linear(3.0)),
value_changed: None, value_changed: None,
// If, for instance, updating this parameter would require other parts of the // 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 // plugin's internal state to be updated other values to also be updated, then you

View file

@ -60,7 +60,7 @@ impl Default for SineParams {
Self { Self {
gain: FloatParam { gain: FloatParam {
value: -10.0, value: -10.0,
smoothed: Smoother::new(SmoothingStyle::SmoothLinear(3.0)), smoothed: Smoother::new(SmoothingStyle::Linear(3.0)),
range: Range::Linear { range: Range::Linear {
min: -30.0, min: -30.0,
max: 0.0, max: 0.0,
@ -72,7 +72,7 @@ impl Default for SineParams {
}, },
frequency: FloatParam { frequency: FloatParam {
value: 420.0, value: 420.0,
smoothed: Smoother::new(SmoothingStyle::SmoothLinear(10.0)), smoothed: Smoother::new(SmoothingStyle::Linear(10.0)),
range: Range::Skewed { range: Range::Skewed {
min: 1.0, min: 1.0,
max: 20_000.0, max: 20_000.0,

View file

@ -20,7 +20,7 @@ pub enum SmoothingStyle {
/// available for the parameters. /// available for the parameters.
None, None,
/// Smooth parameter changes so the . /// Smooth parameter changes so the .
SmoothLinear(f32), Linear(f32),
// TODO: Sample-accurate modes // TODO: Sample-accurate modes
} }
@ -79,13 +79,11 @@ impl Smoother<f32> {
} else { } else {
self.steps_left = match self.style { self.steps_left = match self.style {
SmoothingStyle::None => 1, 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 { self.step_size = match self.style {
SmoothingStyle::None => 0.0, SmoothingStyle::None => 0.0,
SmoothingStyle::SmoothLinear(_) => { SmoothingStyle::Linear(_) => (self.target - self.current) / self.steps_left as f32,
(self.target - self.current) / self.steps_left as f32
}
}; };
} }
} }
@ -102,7 +100,7 @@ impl Smoother<f32> {
} else { } else {
match &self.style { match &self.style {
SmoothingStyle::None => self.current = self.target, 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<i32> {
} else { } else {
self.steps_left = match self.style { self.steps_left = match self.style {
SmoothingStyle::None => 1, 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 { self.step_size = match self.style {
SmoothingStyle::None => 0.0, SmoothingStyle::None => 0.0,
SmoothingStyle::SmoothLinear(_) => { SmoothingStyle::Linear(_) => {
(self.target as f32 - self.current) / self.steps_left as f32 (self.target as f32 - self.current) / self.steps_left as f32
} }
}; };
@ -142,7 +140,7 @@ impl Smoother<i32> {
} else { } else {
match &self.style { match &self.style {
SmoothingStyle::None => self.current = self.target as f32, SmoothingStyle::None => self.current = self.target as f32,
SmoothingStyle::SmoothLinear(_) => self.current += self.step_size, SmoothingStyle::Linear(_) => self.current += self.step_size,
}; };
} }