diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 4e30b9a2..6c8f499b 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -8,10 +8,13 @@ code then it will not be listed here. ## [2022-10-20] +- The `nih_plug::param` module has been renamed to `nih_plug::params`. Code that + only uses the prelude module doesn't need to be changed. - Some items have been moved out of `nih_plug::param::internals`. The main `Params` trait is now located under `nih_plug::param`, and the `PersistentTrait` trait, implementations, and helper functions are now part of - a new `nih_plug::param::persist` module. + a new `nih_plug::param::persist` module. Code importing the `Params` trait + through the prelude module doesn't need to be changed. ## [2022-10-13] diff --git a/nih_plug_derive/src/params.rs b/nih_plug_derive/src/params.rs index 156720f4..10786a62 100644 --- a/nih_plug_derive/src/params.rs +++ b/nih_plug_derive/src/params.rs @@ -332,7 +332,7 @@ pub fn derive_params(input: TokenStream) -> TokenStream { quote! { // This may not be in scope otherwise, used to call .as_ptr() - use ::nih_plug::param::Param; + use ::nih_plug::params::Param; #[allow(unused_mut)] let mut param_map = vec![#(#param_mapping_self_tokens),*]; @@ -354,9 +354,9 @@ pub fn derive_params(input: TokenStream) -> TokenStream { .map(|PersistentField { field, key }| { ( quote! { - match ::nih_plug::param::persist::PersistentField::map( + match ::nih_plug::params::persist::PersistentField::map( &self.#field, - ::nih_plug::param::persist::serialize_field, + ::nih_plug::params::persist::serialize_field, ) { Ok(data) => { serialized.insert(String::from(#key), data); @@ -372,9 +372,9 @@ pub fn derive_params(input: TokenStream) -> TokenStream { }, quote! { #key => { - match ::nih_plug::param::persist::deserialize_field(&data) { + match ::nih_plug::params::persist::deserialize_field(&data) { Ok(deserialized) => { - ::nih_plug::param::persist::PersistentField::set( + ::nih_plug::params::persist::PersistentField::set( &self.#field, deserialized, ); diff --git a/nih_plug_egui/src/lib.rs b/nih_plug_egui/src/lib.rs index ff0513d3..d089cd66 100644 --- a/nih_plug_egui/src/lib.rs +++ b/nih_plug_egui/src/lib.rs @@ -10,7 +10,7 @@ use baseview::{Size, WindowHandle, WindowOpenOptions, WindowScalePolicy}; use crossbeam::atomic::AtomicCell; use egui::Context; use egui_baseview::EguiWindow; -use nih_plug::param::persist::PersistentField; +use nih_plug::params::persist::PersistentField; use nih_plug::prelude::{Editor, GuiContext, ParamSetter, ParentWindowHandle}; use parking_lot::RwLock; use serde::{Deserialize, Serialize}; @@ -63,7 +63,7 @@ where #[derive(Serialize, Deserialize)] pub struct EguiState { /// The window's size in logical pixels before applying `scale_factor`. - #[serde(with = "nih_plug::param::persist::serialize_atomic_cell")] + #[serde(with = "nih_plug::params::persist::serialize_atomic_cell")] size: AtomicCell<(u32, u32)>, /// Whether the editor's window is currently open. #[serde(skip)] diff --git a/nih_plug_iced/src/lib.rs b/nih_plug_iced/src/lib.rs index d6c2a991..202faaff 100644 --- a/nih_plug_iced/src/lib.rs +++ b/nih_plug_iced/src/lib.rs @@ -92,7 +92,7 @@ use baseview::{WindowOpenOptions, WindowScalePolicy}; use crossbeam::atomic::AtomicCell; use crossbeam::channel; -use nih_plug::param::persist::PersistentField; +use nih_plug::params::persist::PersistentField; use nih_plug::prelude::{Editor, GuiContext, ParentWindowHandle}; use serde::{Deserialize, Serialize}; use std::fmt::Debug; @@ -235,7 +235,7 @@ pub trait IcedEditor: 'static + Send + Sync + Sized { #[derive(Serialize, Deserialize)] pub struct IcedState { /// The window's size in logical pixels before applying `scale_factor`. - #[serde(with = "nih_plug::param::persist::serialize_atomic_cell")] + #[serde(with = "nih_plug::params::persist::serialize_atomic_cell")] size: AtomicCell<(u32, u32)>, /// Whether the editor's window is currently open. #[serde(skip)] diff --git a/nih_plug_vizia/src/lib.rs b/nih_plug_vizia/src/lib.rs index 15f981da..6638c9e1 100644 --- a/nih_plug_vizia/src/lib.rs +++ b/nih_plug_vizia/src/lib.rs @@ -5,7 +5,7 @@ use baseview::{WindowHandle, WindowScalePolicy}; use crossbeam::atomic::AtomicCell; -use nih_plug::param::persist::PersistentField; +use nih_plug::params::persist::PersistentField; use nih_plug::prelude::{Editor, GuiContext, ParentWindowHandle}; use serde::{Deserialize, Serialize}; use std::sync::atomic::{AtomicBool, Ordering}; @@ -77,11 +77,11 @@ where #[derive(Serialize, Deserialize)] pub struct ViziaState { /// The window's size in logical pixels before applying `scale_factor`. - #[serde(with = "nih_plug::param::persist::serialize_atomic_cell")] + #[serde(with = "nih_plug::params::persist::serialize_atomic_cell")] size: AtomicCell<(u32, u32)>, /// A scale factor that should be applied to `size` separate from from any system HiDPI scaling. /// This can be used to allow GUIs to be scaled uniformly. - #[serde(with = "nih_plug::param::persist::serialize_atomic_cell")] + #[serde(with = "nih_plug::params::persist::serialize_atomic_cell")] scale_factor: AtomicCell, /// Whether the editor's window is currently open. #[serde(skip)] diff --git a/src/context.rs b/src/context.rs index da9f90ba..8c6a2a9b 100644 --- a/src/context.rs +++ b/src/context.rs @@ -3,8 +3,8 @@ use std::fmt::Display; use crate::midi::NoteEvent; -use crate::param::internals::ParamPtr; -use crate::param::Param; +use crate::params::internals::ParamPtr; +use crate::params::Param; use crate::wrapper::state::PluginState; /// Callbacks the plugin can make while it is being initialized. This is passed to the plugin during @@ -220,7 +220,7 @@ pub struct Transport { } /// A convenience helper for setting parameter values. Any changes made here will be broadcasted to -/// the host and reflected in the plugin's [`Params`][crate::param::Params] object. These +/// the host and reflected in the plugin's [`Params`][crate::params::Params] object. These /// functions should only be called from the main thread. pub struct ParamSetter<'a> { pub raw_context: &'a dyn GuiContext, diff --git a/src/lib.rs b/src/lib.rs index d67eed78..78a27708 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,6 +105,6 @@ pub mod buffer; pub mod context; mod event_loop; pub mod midi; -pub mod param; +pub mod params; pub mod plugin; pub mod wrapper; diff --git a/src/param.rs b/src/params.rs similarity index 100% rename from src/param.rs rename to src/params.rs diff --git a/src/param/boolean.rs b/src/params/boolean.rs similarity index 100% rename from src/param/boolean.rs rename to src/params/boolean.rs diff --git a/src/param/enums.rs b/src/params/enums.rs similarity index 100% rename from src/param/enums.rs rename to src/params/enums.rs diff --git a/src/param/float.rs b/src/params/float.rs similarity index 100% rename from src/param/float.rs rename to src/params/float.rs diff --git a/src/param/integer.rs b/src/params/integer.rs similarity index 100% rename from src/param/integer.rs rename to src/params/integer.rs diff --git a/src/param/internals.rs b/src/params/internals.rs similarity index 100% rename from src/param/internals.rs rename to src/params/internals.rs diff --git a/src/param/persist.rs b/src/params/persist.rs similarity index 97% rename from src/param/persist.rs rename to src/params/persist.rs index 6cb138e3..1363e7b4 100644 --- a/src/param/persist.rs +++ b/src/params/persist.rs @@ -109,7 +109,7 @@ where impl_persistent_field_parking_lot_mutex!(parking_lot::Mutex); impl_persistent_field_parking_lot_mutex!(parking_lot::FairMutex); -/// Can be used with the `#[serde(with = "nih_plug::param::internals::serialize_atomic_cell")]` +/// Can be used with the `#[serde(with = "nih_plug::params::internals::serialize_atomic_cell")]` /// attribute to serialize `AtomicCell`s. pub mod serialize_atomic_cell { use crossbeam::atomic::AtomicCell; diff --git a/src/param/range.rs b/src/params/range.rs similarity index 100% rename from src/param/range.rs rename to src/params/range.rs diff --git a/src/param/smoothing.rs b/src/params/smoothing.rs similarity index 100% rename from src/param/smoothing.rs rename to src/params/smoothing.rs diff --git a/src/plugin.rs b/src/plugin.rs index ef3b4832..0f070451 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use crate::buffer::Buffer; use crate::context::{GuiContext, InitContext, ProcessContext}; use crate::midi::MidiConfig; -use crate::param::Params; +use crate::params::Params; use crate::wrapper::clap::features::ClapFeature; /// Basic functionality that needs to be implemented by a plugin. The wrappers will use this to diff --git a/src/prelude.rs b/src/prelude.rs index a471e74f..f2acc6f5 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -14,12 +14,12 @@ pub use crate::buffer::Buffer; pub use crate::context::{GuiContext, InitContext, ParamSetter, PluginApi, ProcessContext}; // This also includes the derive macro pub use crate::midi::{control_change, MidiConfig, NoteEvent}; -pub use crate::param::enums::{Enum, EnumParam}; -pub use crate::param::internals::ParamPtr; -pub use crate::param::range::{FloatRange, IntRange}; -pub use crate::param::smoothing::{Smoothable, Smoother, SmoothingStyle}; -pub use crate::param::Params; -pub use crate::param::{BoolParam, FloatParam, IntParam, Param, ParamFlags}; +pub use crate::params::enums::{Enum, EnumParam}; +pub use crate::params::internals::ParamPtr; +pub use crate::params::range::{FloatRange, IntRange}; +pub use crate::params::smoothing::{Smoothable, Smoother, SmoothingStyle}; +pub use crate::params::Params; +pub use crate::params::{BoolParam, FloatParam, IntParam, Param, ParamFlags}; pub use crate::plugin::{ AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, Plugin, PolyModulationConfig, PortNames, ProcessMode, ProcessStatus, diff --git a/src/wrapper/clap/context.rs b/src/wrapper/clap/context.rs index 8a58b78b..11f14f72 100644 --- a/src/wrapper/clap/context.rs +++ b/src/wrapper/clap/context.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use super::wrapper::{OutputParamEvent, Wrapper}; use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport}; use crate::midi::NoteEvent; -use crate::param::internals::ParamPtr; +use crate::params::internals::ParamPtr; use crate::plugin::ClapPlugin; /// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 25d2d353..fb93d010 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -80,8 +80,8 @@ use crate::buffer::Buffer; use crate::context::Transport; use crate::event_loop::{EventLoop, MainThreadExecutor, TASK_QUEUE_CAPACITY}; use crate::midi::{MidiConfig, NoteEvent}; -use crate::param::internals::ParamPtr; -use crate::param::{ParamFlags, Params}; +use crate::params::internals::ParamPtr; +use crate::params::{ParamFlags, Params}; use crate::plugin::{ AuxiliaryBuffers, BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, ProcessMode, ProcessStatus, @@ -299,7 +299,7 @@ pub enum OutputParamEvent { /// The internal hash for the parameter. param_hash: u32, /// The 'plain' value as reported to CLAP. This is the normalized value multiplied by - /// [`Param::step_size()`][crate::Param::step_size()]. + /// [`params::step_size()`][crate::params::step_size()]. clap_plain_value: f64, }, /// Begin an automation gesture. This must always be sent after sending one or more [`SetValue`] diff --git a/src/wrapper/standalone/context.rs b/src/wrapper/standalone/context.rs index 9e6feef8..2667581c 100644 --- a/src/wrapper/standalone/context.rs +++ b/src/wrapper/standalone/context.rs @@ -5,7 +5,7 @@ use super::backend::Backend; use super::wrapper::{GuiTask, Wrapper}; use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport}; use crate::midi::NoteEvent; -use crate::param::internals::ParamPtr; +use crate::params::internals::ParamPtr; use crate::plugin::Plugin; /// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in diff --git a/src/wrapper/standalone/wrapper.rs b/src/wrapper/standalone/wrapper.rs index df039dc3..9ffee5fe 100644 --- a/src/wrapper/standalone/wrapper.rs +++ b/src/wrapper/standalone/wrapper.rs @@ -15,8 +15,8 @@ use super::config::WrapperConfig; use super::context::{WrapperGuiContext, WrapperInitContext, WrapperProcessContext}; use crate::context::Transport; use crate::midi::NoteEvent; -use crate::param::internals::ParamPtr; -use crate::param::{ParamFlags, Params}; +use crate::params::internals::ParamPtr; +use crate::params::{ParamFlags, Params}; use crate::plugin::{ AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, Editor, ParentWindowHandle, Plugin, ProcessMode, ProcessStatus, diff --git a/src/wrapper/state.rs b/src/wrapper/state.rs index 7a797117..042cfed8 100644 --- a/src/wrapper/state.rs +++ b/src/wrapper/state.rs @@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap}; use std::sync::Arc; -use crate::param::internals::ParamPtr; -use crate::param::{Param, ParamMut, Params}; +use crate::params::internals::ParamPtr; +use crate::params::{Param, ParamMut, Params}; use crate::plugin::{BufferConfig, Plugin}; // These state objects are also exposed directly to the plugin so it can do its own internal preset @@ -45,7 +45,7 @@ pub struct PluginState { /// parameter automation though, depending on how the host implements that. pub params: BTreeMap, /// Arbitrary fields that should be persisted together with the plugin's parameters. Any field - /// on the [`Params`][crate::param::Params] struct that's annotated with `#[persist = + /// on the [`Params`][crate::params::Params] struct that's annotated with `#[persist = /// "stable_name"]` will be persisted this way. /// /// The individual fields are also serialized as JSON so they can safely be restored diff --git a/src/wrapper/vst3/context.rs b/src/wrapper/vst3/context.rs index 0c427784..7ea3406c 100644 --- a/src/wrapper/vst3/context.rs +++ b/src/wrapper/vst3/context.rs @@ -7,7 +7,7 @@ use vst3_sys::vst::IComponentHandler; use super::inner::{Task, WrapperInner}; use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport}; use crate::midi::NoteEvent; -use crate::param::internals::ParamPtr; +use crate::params::internals::ParamPtr; use crate::plugin::Vst3Plugin; use crate::wrapper::state::PluginState; diff --git a/src/wrapper/vst3/inner.rs b/src/wrapper/vst3/inner.rs index dc5f36f9..2d5be68e 100644 --- a/src/wrapper/vst3/inner.rs +++ b/src/wrapper/vst3/inner.rs @@ -18,8 +18,8 @@ use crate::buffer::Buffer; use crate::context::Transport; use crate::event_loop::{EventLoop, MainThreadExecutor, OsEventLoop}; use crate::midi::{MidiConfig, NoteEvent}; -use crate::param::internals::ParamPtr; -use crate::param::{ParamFlags, Params}; +use crate::params::internals::ParamPtr; +use crate::params::{ParamFlags, Params}; use crate::plugin::{BufferConfig, BusConfig, Editor, ProcessMode, ProcessStatus, Vst3Plugin}; use crate::wrapper::state::{self, PluginState}; use crate::wrapper::util::{hash_param_id, process_wrapper}; diff --git a/src/wrapper/vst3/wrapper.rs b/src/wrapper/vst3/wrapper.rs index 35acca7a..46201819 100644 --- a/src/wrapper/vst3/wrapper.rs +++ b/src/wrapper/vst3/wrapper.rs @@ -26,7 +26,7 @@ use super::view::WrapperView; use crate::buffer::Buffer; use crate::context::Transport; use crate::midi::{MidiConfig, NoteEvent}; -use crate::param::ParamFlags; +use crate::params::ParamFlags; use crate::plugin::{ AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, ProcessMode, ProcessStatus, Vst3Plugin,