1
0
Fork 0

Remove unused Param::set_from_string

This method is a bit more efficient than converting the string to a
normalized value and then setting the parameter using that but it's not
used right now and it adds a form of redundancy.
This commit is contained in:
Robbert van der Helm 2022-03-18 17:53:38 +01:00
parent 47901d9b10
commit fb60f3a28b
6 changed files with 0 additions and 70 deletions

View file

@ -67,12 +67,6 @@ pub trait Param: Display {
/// wrappers. This **does** snap to step sizes for continuous parameters (i.e. [`FloatParam`]).
fn preview_plain(&self, normalized: f32) -> Self::Plain;
/// Set this parameter based on a string. Returns whether the updating succeeded. That can fail
/// if the string cannot be parsed.
///
/// TODO: After implementing VST3, check if we handle parsing failures correctly
fn set_from_string(&mut self, string: &str) -> bool;
/// Update the smoother state to point to the current value. Also used when initializing and
/// restoring a plugin so everything is in sync. In that case the smoother should completely
/// reset to the current value.

View file

@ -116,22 +116,6 @@ impl Param for BoolParam {
normalized > 0.5
}
fn set_from_string(&mut self, string: &str) -> bool {
let string = string.trim();
let value = match &self.string_to_value {
Some(f) => f(string),
None => Some(string.eq_ignore_ascii_case("true") || string.eq_ignore_ascii_case("on")),
};
match value {
Some(plain) => {
self.set_plain_value(plain);
true
}
None => false,
}
}
fn update_smoother(&mut self, _sample_rate: f32, _init: bool) {
// Can't really smooth a binary parameter now can you
}

View file

@ -146,10 +146,6 @@ impl<T: Enum + PartialEq> Param for EnumParam<T> {
T::from_index(self.inner.preview_plain(normalized) as usize)
}
fn set_from_string(&mut self, string: &str) -> bool {
self.inner.set_from_string(string)
}
fn update_smoother(&mut self, sample_rate: f32, reset: bool) {
self.inner.update_smoother(sample_rate, reset)
}
@ -215,17 +211,6 @@ impl Param for EnumParamInner {
self.inner.preview_plain(normalized)
}
fn set_from_string(&mut self, string: &str) -> bool {
let string = string.trim();
match self.variants.iter().position(|variant| variant == &string) {
Some(idx) => {
self.inner.set_plain_value(idx as i32);
true
}
None => false,
}
}
fn update_smoother(&mut self, sample_rate: f32, reset: bool) {
self.inner.update_smoother(sample_rate, reset)
}

View file

@ -166,22 +166,6 @@ impl Param for FloatParam {
}
}
fn set_from_string(&mut self, string: &str) -> bool {
let value = match &self.string_to_value {
Some(f) => f(string.trim()),
// In the CLAP wrapper the unit will be included, so make sure to handle that
None => string.trim().trim_end_matches(self.unit).parse().ok(),
};
match value {
Some(plain) => {
self.set_plain_value(plain);
true
}
None => false,
}
}
fn update_smoother(&mut self, sample_rate: f32, reset: bool) {
if reset {
self.smoothed.reset(self.value);

View file

@ -145,22 +145,6 @@ impl Param for IntParam {
self.range.unnormalize(normalized)
}
fn set_from_string(&mut self, string: &str) -> bool {
let value = match &self.string_to_value {
Some(f) => f(string.trim()),
// In the CLAP wrapper the unit will be included, so make sure to handle that
None => string.trim().trim_end_matches(self.unit).parse().ok(),
};
match value {
Some(plain) => {
self.set_plain_value(plain);
true
}
None => false,
}
}
fn update_smoother(&mut self, sample_rate: f32, reset: bool) {
if reset {
self.smoothed.reset(self.value);

View file

@ -150,7 +150,6 @@ impl ParamPtr {
param_ptr_forward!(pub unsafe fn unit(&self) -> &'static str);
param_ptr_forward!(pub unsafe fn update_smoother(&self, sample_rate: f32, reset: bool));
param_ptr_forward!(pub unsafe fn initialize_block_smoother(&mut self, max_block_size: usize));
param_ptr_forward!(pub unsafe fn set_from_string(&mut self, string: &str) -> bool);
param_ptr_forward!(pub unsafe fn normalized_value(&self) -> f32);
param_ptr_forward!(pub unsafe fn set_normalized_value(&self, normalized: f32));
param_ptr_forward!(pub unsafe fn normalized_value_to_string(&self, normalized: f32, include_unit: bool) -> String);