Store the spectrum on Diopser's editor data struct
This commit is contained in:
parent
b2210072fc
commit
087aea9e53
|
@ -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<DiopserParams>,
|
||||
|
||||
spectrum: Arc<Mutex<SpectrumOutput>>,
|
||||
/// 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<ViziaState> {
|
|||
|
||||
pub(crate) fn create(
|
||||
params: Arc<DiopserParams>,
|
||||
spectrum: Arc<Mutex<SpectrumOutput>>,
|
||||
editor_state: Arc<ViziaState>,
|
||||
) -> Option<Box<dyn Editor>> {
|
||||
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);
|
||||
|
|
|
@ -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<SpectrumOutput>,
|
||||
spectrum_output: Arc<Mutex<SpectrumOutput>>,
|
||||
}
|
||||
|
||||
#[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<Self>) -> Option<Box<dyn Editor>> {
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue