diff --git a/nih_plug_egui/src/editor.rs b/nih_plug_egui/src/editor.rs index 5f40e3a6..4c5aa811 100644 --- a/nih_plug_egui/src/editor.rs +++ b/nih_plug_egui/src/editor.rs @@ -101,11 +101,15 @@ where true } - fn param_values_changed(&self) { + fn param_value_changed(&self, _id: &str, _normalized_value: f32) { // As mentioned above, for now we'll always force a redraw to allow meter widgets to work // correctly. In the future we can use an `Arc` and only force a redraw when // that boolean is set. } + + fn param_values_changed(&self) { + // Same + } } /// The window handle used for [`EguiEditor`]. diff --git a/nih_plug_iced/src/editor.rs b/nih_plug_iced/src/editor.rs index de140245..e90d5c7e 100644 --- a/nih_plug_iced/src/editor.rs +++ b/nih_plug_iced/src/editor.rs @@ -101,12 +101,16 @@ impl Editor for IcedEditorWrapper { true } + fn param_value_changed(&self, _id: &str, _normalized_value: f32) { + // If there's already a paramter change notification in the channel then we don't need + // to do anything else. This avoids queueing up redundant GUI redraws. + // NOTE: We could add an event containing the parameter's ID and the normalized value, but + // these events aren't really necessary for Vizia. + let _ = self.parameter_updates_sender.try_send(ParameterUpdate); + } + fn param_values_changed(&self) { - if self.iced_state.is_open() { - // If there's already a paramter change notification in the channel then we don't need - // to do anything else. This avoids queueing up redundant GUI redraws. - let _ = self.parameter_updates_sender.try_send(ParameterUpdate); - } + let _ = self.parameter_updates_sender.try_send(ParameterUpdate); } } diff --git a/nih_plug_vizia/src/editor.rs b/nih_plug_vizia/src/editor.rs index 12e5f2a0..272cb6c7 100644 --- a/nih_plug_vizia/src/editor.rs +++ b/nih_plug_vizia/src/editor.rs @@ -123,8 +123,15 @@ impl Editor for ViziaEditor { true } - fn param_values_changed(&self) { + fn param_value_changed(&self, _id: &str, _normalized_value: f32) { // This will cause a future idle callback to send a parameters changed event. + // NOTE: We could add an event containing the parameter's ID and the normalized value, but + // these events aren't really necessary for Vizia. + self.emit_parameters_changed_event + .store(true, Ordering::Relaxed); + } + + fn param_values_changed(&self) { self.emit_parameters_changed_event .store(true, Ordering::Relaxed); } diff --git a/src/editor.rs b/src/editor.rs index 67393f30..19ec556d 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -53,13 +53,14 @@ pub trait Editor: Send { /// there. fn set_scale_factor(&self, factor: f32) -> bool; - /// A callback that will be called whenever the parameter values changed while the editor is - /// open. You don't need to do anything with this, but this can be used to force a redraw when - /// the host sends a new value for a parameter or when a parameter change sent to the host gets - /// processed. - /// - /// This function will be called from the **audio thread**. It must thus be lock-free and may - /// not allocate. + /// Called whenever a specific parameter's value has changed while the editor is open. You don't + /// need to do anything with this, but this can be used to force a redraw when the host sends a + /// new value for a parameter or when a parameter change sent to the host gets processed. + fn param_value_changed(&self, id: &str, normalized_value: f32); + + /// Called whenever one or more parameter values changed while the editor is open. This may be + /// called in place of [`param_value_changed()`][Self::param_value_changed()] when multiple + /// parameter values hcange at the same time. For example, when a preset is loaded. fn param_values_changed(&self); // TODO: Reconsider adding a tick function here for the Linux `IRunLoop`. To keep this platform