1
0
Fork 0

Auto-disable Diopser safe mode for older instances

Since this used to not do anything.
This commit is contained in:
Robbert van der Helm 2022-11-29 20:00:21 +01:00
parent 836a72dbc4
commit aca09c49c7
3 changed files with 23 additions and 2 deletions

9
Cargo.lock generated
View file

@ -1085,13 +1085,14 @@ dependencies = [
[[package]] [[package]]
name = "diopser" name = "diopser"
version = "0.3.0" version = "0.4.0"
dependencies = [ dependencies = [
"atomic_float", "atomic_float",
"nih_plug", "nih_plug",
"nih_plug_vizia", "nih_plug_vizia",
"open", "open",
"realfft", "realfft",
"semver 1.0.14",
"triple_buffer", "triple_buffer",
] ]
@ -3809,6 +3810,12 @@ dependencies = [
"semver-parser 0.10.2", "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]] [[package]]
name = "semver-parser" name = "semver-parser"
version = "0.7.0" version = "0.7.0"

View file

@ -1,6 +1,6 @@
[package] [package]
name = "diopser" name = "diopser"
version = "0.3.0" version = "0.4.0"
edition = "2021" edition = "2021"
authors = ["Robbert van der Helm <mail@robbertvanderhelm.nl>"] authors = ["Robbert van der Helm <mail@robbertvanderhelm.nl>"]
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
@ -20,6 +20,7 @@ nih_plug = { path = "../../", features = ["assert_process_allocs"] }
nih_plug_vizia = { path = "../../nih_plug_vizia" } nih_plug_vizia = { path = "../../nih_plug_vizia" }
atomic_float = "0.1" atomic_float = "0.1"
semver = "1.0.14"
# For the GUI # For the GUI
realfft = "3.0" realfft = "3.0"

View file

@ -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 { fn accepts_bus_config(&self, config: &BusConfig) -> bool {
// The SIMD version only supports stereo // The SIMD version only supports stereo
config.num_input_channels == config.num_output_channels && config.num_input_channels == 2 config.num_input_channels == config.num_output_channels && config.num_input_channels == 2