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 {
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

View file

@ -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,

View file

@ -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<f32> {
} 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<f32> {
} 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<i32> {
} 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<i32> {
} 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,
};
}