diff --git a/src/param/boolean.rs b/src/param/boolean.rs index b111b4ce..210f7ca4 100644 --- a/src/param/boolean.rs +++ b/src/param/boolean.rs @@ -162,8 +162,12 @@ impl ParamMut for BoolParam { } fn set_normalized_value(&mut self, normalized: f32) { + // NOTE: The double conversion here is to make sure the state is reproducible. State is + // saved and restored using plain values, and the new normalized value will be + // different from `normalized`. This is not necesasry for the modulation as these + // values are never shown to the host. self.unmodulated_value = self.preview_plain(normalized); - self.unmodulated_normalized_value = normalized; + self.unmodulated_normalized_value = self.preview_normalized(self.unmodulated_value); if self.modulation_offset == 0.0 { self.value = self.unmodulated_value; self.normalized_value = self.unmodulated_normalized_value; diff --git a/src/param/float.rs b/src/param/float.rs index 9ca38598..03e3be76 100644 --- a/src/param/float.rs +++ b/src/param/float.rs @@ -222,8 +222,12 @@ impl ParamMut for FloatParam { } fn set_normalized_value(&mut self, normalized: f32) { + // NOTE: The double conversion here is to make sure the state is reproducible. State is + // saved and restored using plain values, and the new normalized value will be + // different from `normalized`. This is not necesasry for the modulation as these + // values are never shown to the host. self.unmodulated_value = self.preview_plain(normalized); - self.unmodulated_normalized_value = normalized; + self.unmodulated_normalized_value = self.preview_normalized(self.unmodulated_value); if self.modulation_offset == 0.0 { self.value = self.unmodulated_value; self.normalized_value = self.unmodulated_normalized_value; diff --git a/src/param/integer.rs b/src/param/integer.rs index efd71134..4bb2c13f 100644 --- a/src/param/integer.rs +++ b/src/param/integer.rs @@ -187,8 +187,12 @@ impl ParamMut for IntParam { } fn set_normalized_value(&mut self, normalized: f32) { + // NOTE: The double conversion here is to make sure the state is reproducible. State is + // saved and restored using plain values, and the new normalized value will be + // different from `normalized`. This is not necesasry for the modulation as these + // values are never shown to the host. self.unmodulated_value = self.preview_plain(normalized); - self.unmodulated_normalized_value = normalized; + self.unmodulated_normalized_value = self.preview_normalized(self.unmodulated_value); if self.modulation_offset == 0.0 { self.value = self.unmodulated_value; self.normalized_value = self.unmodulated_normalized_value;