From 6f67235c15c39ca9c2bd30acb22750f6127289ef Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 31 Jan 2022 21:24:26 +0100 Subject: [PATCH] Show off the Default shorthand --- plugins/gain/src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/gain/src/lib.rs b/plugins/gain/src/lib.rs index 7da85b83..51802ae8 100644 --- a/plugins/gain/src/lib.rs +++ b/plugins/gain/src/lib.rs @@ -19,7 +19,7 @@ extern crate nih_plug; use nih_plug::{ formatters, - params::{FloatParam, Param, Params, Range}, + params::{BoolParam, FloatParam, Param, Params, Range}, plugin::{BufferConfig, BusConfig, Plugin, ProcessStatus, Vst3Plugin}, util, }; @@ -35,6 +35,9 @@ struct GainParams { #[id = "gain"] pub gain: FloatParam, + #[id = "as_long_as_this_name_stays_constant"] + pub the_field_name_can_change: BoolParam, + /// This field isn't used in this exampleq, but anything written to the vector would be restored /// together with a preset/state file saved for this plugin. This can be useful for storign /// things like sample data. @@ -70,6 +73,13 @@ impl Default for GainParams { value_to_string: formatters::f32_rounded(2), string_to_value: None, }, + // For brevity's sake you can also use the default values. Don't forget to set the field + // name, default value, and range though. + the_field_name_can_change: BoolParam { + value: false, + name: "Important Value", + ..BoolParam::default() + }, random_data: RwLock::new(Vec::new()), } }