1
0
Fork 0

Recompute normalized values when setting params

This makes it so that the value is consistent after reloading the
preset.
This commit is contained in:
Robbert van der Helm 2022-07-02 19:04:43 +02:00
parent 883b43b6a7
commit 71efe779a5
3 changed files with 15 additions and 3 deletions

View file

@ -162,8 +162,12 @@ impl ParamMut for BoolParam {
} }
fn set_normalized_value(&mut self, normalized: f32) { 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_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 { if self.modulation_offset == 0.0 {
self.value = self.unmodulated_value; self.value = self.unmodulated_value;
self.normalized_value = self.unmodulated_normalized_value; self.normalized_value = self.unmodulated_normalized_value;

View file

@ -222,8 +222,12 @@ impl ParamMut for FloatParam {
} }
fn set_normalized_value(&mut self, normalized: f32) { 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_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 { if self.modulation_offset == 0.0 {
self.value = self.unmodulated_value; self.value = self.unmodulated_value;
self.normalized_value = self.unmodulated_normalized_value; self.normalized_value = self.unmodulated_normalized_value;

View file

@ -187,8 +187,12 @@ impl ParamMut for IntParam {
} }
fn set_normalized_value(&mut self, normalized: f32) { 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_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 { if self.modulation_offset == 0.0 {
self.value = self.unmodulated_value; self.value = self.unmodulated_value;
self.normalized_value = self.unmodulated_normalized_value; self.normalized_value = self.unmodulated_normalized_value;