diff --git a/plugins/diopser/src/editor.rs b/plugins/diopser/src/editor.rs index 49874bbf..02f9f550 100644 --- a/plugins/diopser/src/editor.rs +++ b/plugins/diopser/src/editor.rs @@ -20,9 +20,10 @@ use nih_plug_vizia::vizia::prelude::*; use nih_plug_vizia::widgets::*; use nih_plug_vizia::{assets, create_vizia_editor, ViziaState, ViziaTheming}; use std::sync::atomic::AtomicBool; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use self::button::SafeModeButton; +use crate::spectrum::SpectrumOutput; use crate::{Diopser, DiopserParams}; mod button; @@ -40,6 +41,7 @@ const DARKER_GRAY: Color = Color::rgb(0x69, 0x69, 0x69); struct Data { params: Arc, + spectrum: Arc>, /// Whether the safe mode button is enabled. The number of filter stages is capped at 40 while /// this is active. /// TODO: Actually hook up safe mode @@ -55,6 +57,7 @@ pub(crate) fn default_state() -> Arc { pub(crate) fn create( params: Arc, + spectrum: Arc>, editor_state: Arc, ) -> Option> { create_vizia_editor(editor_state, ViziaTheming::Custom, move |cx, _| { @@ -66,6 +69,7 @@ pub(crate) fn create( Data { params: params.clone(), + spectrum: spectrum.clone(), safe_mode: params.safe_mode.clone(), } .build(cx); diff --git a/plugins/diopser/src/lib.rs b/plugins/diopser/src/lib.rs index d4e92dba..67a1d624 100644 --- a/plugins/diopser/src/lib.rs +++ b/plugins/diopser/src/lib.rs @@ -24,7 +24,7 @@ use nih_plug::prelude::*; use nih_plug_vizia::ViziaState; use std::simd::f32x2; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use crate::spectrum::{SpectrumInput, SpectrumOutput}; @@ -78,7 +78,7 @@ pub struct Diopser { /// When the GUI is open we compute the spectrum on the audio thread and send it to the GUI. spectrum_input: SpectrumInput, /// This can be cloned and moved into the editor. - spectrum_output: Arc, + spectrum_output: Arc>, } #[derive(Params)] @@ -158,7 +158,7 @@ impl Default for Diopser { next_filter_smoothing_in: 1, spectrum_input, - spectrum_output: Arc::new(spectrum_output), + spectrum_output: Arc::new(Mutex::new(spectrum_output)), } } } @@ -298,7 +298,11 @@ impl Plugin for Diopser { } fn editor(&self, _async_executor: AsyncExecutor) -> Option> { - editor::create(self.params.clone(), self.params.editor_state.clone()) + editor::create( + self.params.clone(), + self.spectrum_output.clone(), + self.params.editor_state.clone(), + ) } fn accepts_bus_config(&self, config: &BusConfig) -> bool {