From 6e7ee125b6f0a399b9942bd9eb15441ef223765e Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 10 Jan 2023 20:24:51 +0100 Subject: [PATCH] Sorta fix stock widget usage in gain_gui_egui The parameter changed from storing its value as decibels to storing gain at some point. --- plugins/examples/gain_gui_egui/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/examples/gain_gui_egui/src/lib.rs b/plugins/examples/gain_gui_egui/src/lib.rs index 38ec79e6..570b7655 100644 --- a/plugins/examples/gain_gui_egui/src/lib.rs +++ b/plugins/examples/gain_gui_egui/src/lib.rs @@ -117,13 +117,16 @@ impl Plugin for Gain { ui.add( egui::widgets::Slider::from_get_set(-30.0..=30.0, |new_value| { match new_value { - Some(new_value) => { + Some(new_value_db) => { + let new_value = util::gain_to_db(new_value_db as f32); + setter.begin_set_parameter(¶ms.gain); - setter.set_parameter(¶ms.gain, new_value as f32); + setter.set_parameter(¶ms.gain, new_value); setter.end_set_parameter(¶ms.gain); - new_value + + new_value_db } - None => params.gain.value() as f64, + None => util::gain_to_db(params.gain.value()) as f64, } }) .suffix(" dB"),