1
0
Fork 0

Move nih_plug::param to nih_plug::params

This commit is contained in:
Robbert van der Helm 2022-10-20 12:26:12 +02:00
parent e1269d07b1
commit bd295b7380
26 changed files with 42 additions and 39 deletions

View file

@ -8,10 +8,13 @@ code then it will not be listed here.
## [2022-10-20] ## [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 - Some items have been moved out of `nih_plug::param::internals`. The main
`Params` trait is now located under `nih_plug::param`, and the `Params` trait is now located under `nih_plug::param`, and the
`PersistentTrait` trait, implementations, and helper functions are now part of `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] ## [2022-10-13]

View file

@ -332,7 +332,7 @@ pub fn derive_params(input: TokenStream) -> TokenStream {
quote! { quote! {
// This may not be in scope otherwise, used to call .as_ptr() // 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)] #[allow(unused_mut)]
let mut param_map = vec![#(#param_mapping_self_tokens),*]; let mut param_map = vec![#(#param_mapping_self_tokens),*];
@ -354,9 +354,9 @@ pub fn derive_params(input: TokenStream) -> TokenStream {
.map(|PersistentField { field, key }| { .map(|PersistentField { field, key }| {
( (
quote! { quote! {
match ::nih_plug::param::persist::PersistentField::map( match ::nih_plug::params::persist::PersistentField::map(
&self.#field, &self.#field,
::nih_plug::param::persist::serialize_field, ::nih_plug::params::persist::serialize_field,
) { ) {
Ok(data) => { Ok(data) => {
serialized.insert(String::from(#key), data); serialized.insert(String::from(#key), data);
@ -372,9 +372,9 @@ pub fn derive_params(input: TokenStream) -> TokenStream {
}, },
quote! { quote! {
#key => { #key => {
match ::nih_plug::param::persist::deserialize_field(&data) { match ::nih_plug::params::persist::deserialize_field(&data) {
Ok(deserialized) => { Ok(deserialized) => {
::nih_plug::param::persist::PersistentField::set( ::nih_plug::params::persist::PersistentField::set(
&self.#field, &self.#field,
deserialized, deserialized,
); );

View file

@ -10,7 +10,7 @@ use baseview::{Size, WindowHandle, WindowOpenOptions, WindowScalePolicy};
use crossbeam::atomic::AtomicCell; use crossbeam::atomic::AtomicCell;
use egui::Context; use egui::Context;
use egui_baseview::EguiWindow; 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 nih_plug::prelude::{Editor, GuiContext, ParamSetter, ParentWindowHandle};
use parking_lot::RwLock; use parking_lot::RwLock;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -63,7 +63,7 @@ where
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct EguiState { pub struct EguiState {
/// The window's size in logical pixels before applying `scale_factor`. /// 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)>, size: AtomicCell<(u32, u32)>,
/// Whether the editor's window is currently open. /// Whether the editor's window is currently open.
#[serde(skip)] #[serde(skip)]

View file

@ -92,7 +92,7 @@
use baseview::{WindowOpenOptions, WindowScalePolicy}; use baseview::{WindowOpenOptions, WindowScalePolicy};
use crossbeam::atomic::AtomicCell; use crossbeam::atomic::AtomicCell;
use crossbeam::channel; use crossbeam::channel;
use nih_plug::param::persist::PersistentField; use nih_plug::params::persist::PersistentField;
use nih_plug::prelude::{Editor, GuiContext, ParentWindowHandle}; use nih_plug::prelude::{Editor, GuiContext, ParentWindowHandle};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fmt::Debug; use std::fmt::Debug;
@ -235,7 +235,7 @@ pub trait IcedEditor: 'static + Send + Sync + Sized {
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct IcedState { pub struct IcedState {
/// The window's size in logical pixels before applying `scale_factor`. /// 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)>, size: AtomicCell<(u32, u32)>,
/// Whether the editor's window is currently open. /// Whether the editor's window is currently open.
#[serde(skip)] #[serde(skip)]

View file

@ -5,7 +5,7 @@
use baseview::{WindowHandle, WindowScalePolicy}; use baseview::{WindowHandle, WindowScalePolicy};
use crossbeam::atomic::AtomicCell; use crossbeam::atomic::AtomicCell;
use nih_plug::param::persist::PersistentField; use nih_plug::params::persist::PersistentField;
use nih_plug::prelude::{Editor, GuiContext, ParentWindowHandle}; use nih_plug::prelude::{Editor, GuiContext, ParentWindowHandle};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@ -77,11 +77,11 @@ where
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct ViziaState { pub struct ViziaState {
/// The window's size in logical pixels before applying `scale_factor`. /// 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)>, size: AtomicCell<(u32, u32)>,
/// A scale factor that should be applied to `size` separate from from any system HiDPI scaling. /// 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. /// 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<f64>, scale_factor: AtomicCell<f64>,
/// Whether the editor's window is currently open. /// Whether the editor's window is currently open.
#[serde(skip)] #[serde(skip)]

View file

@ -3,8 +3,8 @@
use std::fmt::Display; use std::fmt::Display;
use crate::midi::NoteEvent; use crate::midi::NoteEvent;
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::param::Param; use crate::params::Param;
use crate::wrapper::state::PluginState; use crate::wrapper::state::PluginState;
/// Callbacks the plugin can make while it is being initialized. This is passed to the plugin during /// 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 /// 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. /// functions should only be called from the main thread.
pub struct ParamSetter<'a> { pub struct ParamSetter<'a> {
pub raw_context: &'a dyn GuiContext, pub raw_context: &'a dyn GuiContext,

View file

@ -105,6 +105,6 @@ pub mod buffer;
pub mod context; pub mod context;
mod event_loop; mod event_loop;
pub mod midi; pub mod midi;
pub mod param; pub mod params;
pub mod plugin; pub mod plugin;
pub mod wrapper; pub mod wrapper;

View file

@ -109,7 +109,7 @@ where
impl_persistent_field_parking_lot_mutex!(parking_lot::Mutex<T>); impl_persistent_field_parking_lot_mutex!(parking_lot::Mutex<T>);
impl_persistent_field_parking_lot_mutex!(parking_lot::FairMutex<T>); impl_persistent_field_parking_lot_mutex!(parking_lot::FairMutex<T>);
/// 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<T>`s. /// attribute to serialize `AtomicCell<T>`s.
pub mod serialize_atomic_cell { pub mod serialize_atomic_cell {
use crossbeam::atomic::AtomicCell; use crossbeam::atomic::AtomicCell;

View file

@ -7,7 +7,7 @@ use std::sync::Arc;
use crate::buffer::Buffer; use crate::buffer::Buffer;
use crate::context::{GuiContext, InitContext, ProcessContext}; use crate::context::{GuiContext, InitContext, ProcessContext};
use crate::midi::MidiConfig; use crate::midi::MidiConfig;
use crate::param::Params; use crate::params::Params;
use crate::wrapper::clap::features::ClapFeature; use crate::wrapper::clap::features::ClapFeature;
/// Basic functionality that needs to be implemented by a plugin. The wrappers will use this to /// Basic functionality that needs to be implemented by a plugin. The wrappers will use this to

View file

@ -14,12 +14,12 @@ pub use crate::buffer::Buffer;
pub use crate::context::{GuiContext, InitContext, ParamSetter, PluginApi, ProcessContext}; pub use crate::context::{GuiContext, InitContext, ParamSetter, PluginApi, ProcessContext};
// This also includes the derive macro // This also includes the derive macro
pub use crate::midi::{control_change, MidiConfig, NoteEvent}; pub use crate::midi::{control_change, MidiConfig, NoteEvent};
pub use crate::param::enums::{Enum, EnumParam}; pub use crate::params::enums::{Enum, EnumParam};
pub use crate::param::internals::ParamPtr; pub use crate::params::internals::ParamPtr;
pub use crate::param::range::{FloatRange, IntRange}; pub use crate::params::range::{FloatRange, IntRange};
pub use crate::param::smoothing::{Smoothable, Smoother, SmoothingStyle}; pub use crate::params::smoothing::{Smoothable, Smoother, SmoothingStyle};
pub use crate::param::Params; pub use crate::params::Params;
pub use crate::param::{BoolParam, FloatParam, IntParam, Param, ParamFlags}; pub use crate::params::{BoolParam, FloatParam, IntParam, Param, ParamFlags};
pub use crate::plugin::{ pub use crate::plugin::{
AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, ClapPlugin, Editor, AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, ClapPlugin, Editor,
ParentWindowHandle, Plugin, PolyModulationConfig, PortNames, ProcessMode, ProcessStatus, ParentWindowHandle, Plugin, PolyModulationConfig, PortNames, ProcessMode, ProcessStatus,

View file

@ -5,7 +5,7 @@ use std::sync::Arc;
use super::wrapper::{OutputParamEvent, Wrapper}; use super::wrapper::{OutputParamEvent, Wrapper};
use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport}; use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport};
use crate::midi::NoteEvent; use crate::midi::NoteEvent;
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::plugin::ClapPlugin; use crate::plugin::ClapPlugin;
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in /// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in

View file

@ -80,8 +80,8 @@ use crate::buffer::Buffer;
use crate::context::Transport; use crate::context::Transport;
use crate::event_loop::{EventLoop, MainThreadExecutor, TASK_QUEUE_CAPACITY}; use crate::event_loop::{EventLoop, MainThreadExecutor, TASK_QUEUE_CAPACITY};
use crate::midi::{MidiConfig, NoteEvent}; use crate::midi::{MidiConfig, NoteEvent};
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::param::{ParamFlags, Params}; use crate::params::{ParamFlags, Params};
use crate::plugin::{ use crate::plugin::{
AuxiliaryBuffers, BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, ProcessMode, AuxiliaryBuffers, BufferConfig, BusConfig, ClapPlugin, Editor, ParentWindowHandle, ProcessMode,
ProcessStatus, ProcessStatus,
@ -299,7 +299,7 @@ pub enum OutputParamEvent {
/// The internal hash for the parameter. /// The internal hash for the parameter.
param_hash: u32, param_hash: u32,
/// The 'plain' value as reported to CLAP. This is the normalized value multiplied by /// 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, clap_plain_value: f64,
}, },
/// Begin an automation gesture. This must always be sent after sending one or more [`SetValue`] /// Begin an automation gesture. This must always be sent after sending one or more [`SetValue`]

View file

@ -5,7 +5,7 @@ use super::backend::Backend;
use super::wrapper::{GuiTask, Wrapper}; use super::wrapper::{GuiTask, Wrapper};
use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport}; use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport};
use crate::midi::NoteEvent; use crate::midi::NoteEvent;
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::plugin::Plugin; use crate::plugin::Plugin;
/// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in /// A [`GuiContext`] implementation for the wrapper. This is passed to the plugin in

View file

@ -15,8 +15,8 @@ use super::config::WrapperConfig;
use super::context::{WrapperGuiContext, WrapperInitContext, WrapperProcessContext}; use super::context::{WrapperGuiContext, WrapperInitContext, WrapperProcessContext};
use crate::context::Transport; use crate::context::Transport;
use crate::midi::NoteEvent; use crate::midi::NoteEvent;
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::param::{ParamFlags, Params}; use crate::params::{ParamFlags, Params};
use crate::plugin::{ use crate::plugin::{
AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, Editor, ParentWindowHandle, AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, Editor, ParentWindowHandle,
Plugin, ProcessMode, ProcessStatus, Plugin, ProcessMode, ProcessStatus,

View file

@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
use std::sync::Arc; use std::sync::Arc;
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::param::{Param, ParamMut, Params}; use crate::params::{Param, ParamMut, Params};
use crate::plugin::{BufferConfig, Plugin}; use crate::plugin::{BufferConfig, Plugin};
// These state objects are also exposed directly to the plugin so it can do its own internal preset // 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. /// parameter automation though, depending on how the host implements that.
pub params: BTreeMap<String, ParamValue>, pub params: BTreeMap<String, ParamValue>,
/// Arbitrary fields that should be persisted together with the plugin's parameters. Any field /// 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. /// "stable_name"]` will be persisted this way.
/// ///
/// The individual fields are also serialized as JSON so they can safely be restored /// The individual fields are also serialized as JSON so they can safely be restored

View file

@ -7,7 +7,7 @@ use vst3_sys::vst::IComponentHandler;
use super::inner::{Task, WrapperInner}; use super::inner::{Task, WrapperInner};
use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport}; use crate::context::{GuiContext, InitContext, PluginApi, ProcessContext, Transport};
use crate::midi::NoteEvent; use crate::midi::NoteEvent;
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::plugin::Vst3Plugin; use crate::plugin::Vst3Plugin;
use crate::wrapper::state::PluginState; use crate::wrapper::state::PluginState;

View file

@ -18,8 +18,8 @@ use crate::buffer::Buffer;
use crate::context::Transport; use crate::context::Transport;
use crate::event_loop::{EventLoop, MainThreadExecutor, OsEventLoop}; use crate::event_loop::{EventLoop, MainThreadExecutor, OsEventLoop};
use crate::midi::{MidiConfig, NoteEvent}; use crate::midi::{MidiConfig, NoteEvent};
use crate::param::internals::ParamPtr; use crate::params::internals::ParamPtr;
use crate::param::{ParamFlags, Params}; use crate::params::{ParamFlags, Params};
use crate::plugin::{BufferConfig, BusConfig, Editor, ProcessMode, ProcessStatus, Vst3Plugin}; use crate::plugin::{BufferConfig, BusConfig, Editor, ProcessMode, ProcessStatus, Vst3Plugin};
use crate::wrapper::state::{self, PluginState}; use crate::wrapper::state::{self, PluginState};
use crate::wrapper::util::{hash_param_id, process_wrapper}; use crate::wrapper::util::{hash_param_id, process_wrapper};

View file

@ -26,7 +26,7 @@ use super::view::WrapperView;
use crate::buffer::Buffer; use crate::buffer::Buffer;
use crate::context::Transport; use crate::context::Transport;
use crate::midi::{MidiConfig, NoteEvent}; use crate::midi::{MidiConfig, NoteEvent};
use crate::param::ParamFlags; use crate::params::ParamFlags;
use crate::plugin::{ use crate::plugin::{
AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, ProcessMode, ProcessStatus, AuxiliaryBuffers, AuxiliaryIOConfig, BufferConfig, BusConfig, ProcessMode, ProcessStatus,
Vst3Plugin, Vst3Plugin,