Add a not yet used safe mode AtomicBool to Diopser
This will limit the range of the filter stages parameter in the GUI.
This commit is contained in:
parent
d7f1f1e85f
commit
2d4ac47f15
|
@ -18,6 +18,7 @@ use nih_plug::prelude::Editor;
|
||||||
use nih_plug_vizia::vizia::prelude::*;
|
use nih_plug_vizia::vizia::prelude::*;
|
||||||
use nih_plug_vizia::widgets::*;
|
use nih_plug_vizia::widgets::*;
|
||||||
use nih_plug_vizia::{assets, create_vizia_editor, ViziaState, ViziaTheming};
|
use nih_plug_vizia::{assets, create_vizia_editor, ViziaState, ViziaTheming};
|
||||||
|
use std::sync::atomic::AtomicBool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::DiopserParams;
|
use crate::DiopserParams;
|
||||||
|
@ -28,6 +29,10 @@ const POINT_SCALE: f32 = 0.75;
|
||||||
#[derive(Lens)]
|
#[derive(Lens)]
|
||||||
struct Data {
|
struct Data {
|
||||||
params: Arc<DiopserParams>,
|
params: Arc<DiopserParams>,
|
||||||
|
|
||||||
|
/// Whether the safe mode button is enabled. The number of filter stages is capped at 40 while
|
||||||
|
/// this is active.
|
||||||
|
safe_mode: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Model for Data {}
|
impl Model for Data {}
|
||||||
|
@ -49,6 +54,8 @@ pub(crate) fn create(
|
||||||
|
|
||||||
Data {
|
Data {
|
||||||
params: params.clone(),
|
params: params.clone(),
|
||||||
|
|
||||||
|
safe_mode: params.safe_mode.clone(),
|
||||||
}
|
}
|
||||||
.build(cx);
|
.build(cx);
|
||||||
|
|
||||||
|
|
|
@ -72,14 +72,16 @@ pub struct Diopser {
|
||||||
spectrum_output: Arc<SpectrumOutput>,
|
spectrum_output: Arc<SpectrumOutput>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Some combinations of parameters can cause really loud resonance. We should limit the
|
|
||||||
// resonance and filter stages parameter ranges in the GUI until the user unlocks.
|
|
||||||
#[derive(Params)]
|
#[derive(Params)]
|
||||||
struct DiopserParams {
|
struct DiopserParams {
|
||||||
/// The editor state, saved together with the parameter state so the custom scaling can be
|
/// The editor state, saved together with the parameter state so the custom scaling can be
|
||||||
/// restored.
|
/// restored.
|
||||||
#[persist = "editor-state"]
|
#[persist = "editor-state"]
|
||||||
editor_state: Arc<ViziaState>,
|
editor_state: Arc<ViziaState>,
|
||||||
|
/// If this option is enabled, then the filter stages parameter is limited to `[0, 40]`. This is
|
||||||
|
/// editor-only state, and doesn't affect host automation.
|
||||||
|
#[persist = "safe-mode"]
|
||||||
|
safe_mode: Arc<AtomicBool>,
|
||||||
|
|
||||||
/// This plugin really doesn't need its own bypass parameter, but it's still useful to have a
|
/// This plugin really doesn't need its own bypass parameter, but it's still useful to have a
|
||||||
/// dedicated one so it can be shown in the GUI. This is linked to the host's bypass if the host
|
/// dedicated one so it can be shown in the GUI. This is linked to the host's bypass if the host
|
||||||
|
@ -149,6 +151,7 @@ impl DiopserParams {
|
||||||
fn new(should_update_filters: Arc<AtomicBool>) -> Self {
|
fn new(should_update_filters: Arc<AtomicBool>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
editor_state: editor::default_state(),
|
editor_state: editor::default_state(),
|
||||||
|
safe_mode: Arc::new(AtomicBool::new(true)),
|
||||||
|
|
||||||
bypass: BoolParam::new("Bypass", false).make_bypass(),
|
bypass: BoolParam::new("Bypass", false).make_bypass(),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue