From aca09c49c74ba770b8069c59c52fbfd833bcae93 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 29 Nov 2022 20:00:21 +0100 Subject: [PATCH] Auto-disable Diopser safe mode for older instances Since this used to not do anything. --- Cargo.lock | 9 ++++++++- plugins/diopser/Cargo.toml | 3 ++- plugins/diopser/src/lib.rs | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 628fff69..f6d88cf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1085,13 +1085,14 @@ dependencies = [ [[package]] name = "diopser" -version = "0.3.0" +version = "0.4.0" dependencies = [ "atomic_float", "nih_plug", "nih_plug_vizia", "open", "realfft", + "semver 1.0.14", "triple_buffer", ] @@ -3809,6 +3810,12 @@ dependencies = [ "semver-parser 0.10.2", ] +[[package]] +name = "semver" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" + [[package]] name = "semver-parser" version = "0.7.0" diff --git a/plugins/diopser/Cargo.toml b/plugins/diopser/Cargo.toml index 4b41f05b..d6703970 100644 --- a/plugins/diopser/Cargo.toml +++ b/plugins/diopser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "diopser" -version = "0.3.0" +version = "0.4.0" edition = "2021" authors = ["Robbert van der Helm "] license = "GPL-3.0-or-later" @@ -20,6 +20,7 @@ nih_plug = { path = "../../", features = ["assert_process_allocs"] } nih_plug_vizia = { path = "../../nih_plug_vizia" } atomic_float = "0.1" +semver = "1.0.14" # For the GUI realfft = "3.0" diff --git a/plugins/diopser/src/lib.rs b/plugins/diopser/src/lib.rs index b6d6f9b4..a47a0113 100644 --- a/plugins/diopser/src/lib.rs +++ b/plugins/diopser/src/lib.rs @@ -137,6 +137,19 @@ impl Plugin for Diopser { ) } + fn filter_state(state: &mut PluginState) { + // Safe-mode is enabled by default, so to avoid changing the behavior we'll keep it disabled + // for older presets + if semver::Version::parse(&state.version) + .map(|version| version < semver::Version::parse("0.4.0").unwrap()) + .unwrap_or(true) + { + state + .fields + .insert(String::from("safe-mode"), String::from("false")); + } + } + fn accepts_bus_config(&self, config: &BusConfig) -> bool { // The SIMD version only supports stereo config.num_input_channels == config.num_output_channels && config.num_input_channels == 2