Struct nih_plug::params::BoolParam

source ·
pub struct BoolParam { /* private fields */ }
Expand description

A simple boolean parameter.

Implementations§

source§

impl BoolParam

source

pub fn new(name: impl Into<String>, default: bool) -> Self

Build a new BoolParam. Use the other associated functions to modify the behavior of the parameter.

source

pub fn value(&self) -> bool

The field’s current plain value, after monophonic modulation has been applied. Equivalent to calling param.plain_value().

source

pub fn with_poly_modulation_id(self, id: u32) -> Self

Enable polyphonic modulation for this parameter. The ID is used to uniquely identify this parameter in NoteEvent::PolyModulation events, and must thus be unique between all polyphonically modulatable parameters. See the event’s documentation on how to use polyphonic modulation. Also consider configuring the ClapPlugin::CLAP_POLY_MODULATION_CONFIG constant when enabling this.

Important

After enabling polyphonic modulation, the plugin must start sending NoteEvent::VoiceTerminated events to the host when a voice has fully ended. This allows the host to reuse its modulation resources.

source

pub fn with_callback(self, callback: Arc<dyn Fn(bool) + Send + Sync>) -> Self

Run a callback whenever this parameter’s value changes. The argument passed to this function is the parameter’s new value. This should not do anything expensive as it may be called multiple times in rapid succession, and it can be run from both the GUI and the audio thread.

source

pub fn with_value_to_string( self, callback: Arc<dyn Fn(bool) -> String + Send + Sync> ) -> Self

Use a custom conversion function to convert the boolean value to a string.

source

pub fn with_string_to_value( self, callback: Arc<dyn Fn(&str) -> Option<bool> + Send + Sync> ) -> Self

Use a custom conversion function to convert from a string to a boolean value. If the string cannot be parsed, then this should return a None. If this happens while the parameter is being updated then the update will be canceled.

source

pub fn make_bypass(self) -> Self

Mark this parameter as a bypass parameter. Plugin hosts can integrate this parameter into their UI. Only a single BoolParam can be a bypass parameter, and NIH-plug will add one if you don’t create one yourself. You will need to implement this yourself if your plugin introduces latency.

source

pub fn non_automatable(self) -> Self

Mark the parameter as non-automatable. This means that the parameter cannot be changed from an automation lane. The parameter can however still be manually changed by the user from either the plugin’s own GUI or from the host’s generic UI.

source

pub fn hide(self) -> Self

Hide the parameter in the host’s generic UI for this plugin. This also implies NON_AUTOMATABLE. Setting this does not prevent you from changing the parameter in the plugin’s editor GUI.

source

pub fn hide_in_generic_ui(self) -> Self

Don’t show this parameter when generating a generic UI for the plugin using one of NIH-plug’s generic UI widgets.

Trait Implementations§

source§

impl Debug for BoolParam

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for BoolParam

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Param for BoolParam

§

type Plain = bool

The plain parameter type.
source§

fn name(&self) -> &str

Get the human readable name for this parameter.
source§

fn unit(&self) -> &'static str

Get the unit label for this parameter, if any.
source§

fn poly_modulation_id(&self) -> Option<u32>

Get this parameter’s polyphonic modulation ID. If this is set for a parameter in a CLAP plugin, then polyphonic modulation will be enabled for that parameter. Polyphonic modulation is communicated to the plugin through NoteEvent::PolyModulation and NoteEvent::MonoAutomation events. See the documentation on those events for more information. Read more
source§

fn modulated_plain_value(&self) -> Self::Plain

Get the unnormalized value for this parameter.
source§

fn modulated_normalized_value(&self) -> f32

Get the normalized [0, 1] value for this parameter.
source§

fn unmodulated_plain_value(&self) -> Self::Plain

Get the unnormalized value for this parameter before any (monophonic) modulation coming from the host has been applied. If the host is not currently modulating this parameter than this will be the same as modulated_plain_value(). This may be useful for displaying modulation differently in plugin GUIs. Right now only CLAP plugins in Bitwig Studio use modulation.
source§

fn unmodulated_normalized_value(&self) -> f32

Get the normalized [0, 1] value for this parameter before any (monophonic) modulation coming from the host has been applied. If the host is not currently modulating this parameter than this will be the same as modulated_normalized_value(). This may be useful for displaying modulation differently in plugin GUIs. Right now only CLAP plugins in Bitwig Studio use modulation.
source§

fn default_plain_value(&self) -> Self::Plain

Get the unnormalized default value for this parameter.
source§

fn step_count(&self) -> Option<usize>

Get the number of steps for this parameter, if it is discrete. Used for the host’s generic UI.
source§

fn previous_step(&self, _from: Self::Plain, _finer: bool) -> Self::Plain

Returns the previous step from a specific value for this parameter. This can be the same as from if the value is at the start of its range. This is mainly used for scroll wheel interaction in plugin GUIs. When the parameter is not discrete then a step should cover one hundredth of the normalized range instead. Read more
source§

fn next_step(&self, _from: Self::Plain, _finer: bool) -> Self::Plain

Returns the next step from a specific value for this parameter. This can be the same as from if the value is at the end of its range. This is mainly used for scroll wheel interaction in plugin GUIs. When the parameter is not discrete then a step should cover one hundredth of the normalized range instead. Read more
source§

fn normalized_value_to_string( &self, normalized: f32, _include_unit: bool ) -> String

Get the string representation for a normalized value. Used as part of the wrappers. Most plugin formats already have support for units, in which case it shouldn’t be part of this string or some DAWs may show duplicate units.
source§

fn string_to_normalized_value(&self, string: &str) -> Option<f32>

Get the string representation for a normalized value. Used as part of the wrappers.
source§

fn preview_normalized(&self, plain: Self::Plain) -> f32

Get the normalized value for a plain, unnormalized value, as a float. Used as part of the wrappers.
source§

fn preview_plain(&self, normalized: f32) -> Self::Plain

Get the plain, unnormalized value for a normalized value, as a float. Used as part of the wrappers. This does snap to step sizes for continuous parameters (i.e. FloatParam).
source§

fn flags(&self) -> ParamFlags

Flags to control the parameter’s behavior. See ParamFlags.
source§

fn as_ptr(&self) -> ParamPtr

Internal implementation detail for implementing Params. This should not be used directly.
source§

fn default_normalized_value(&self) -> f32

Get the normalized [0, 1] default value for this parameter.
source§

fn previous_normalized_step(&self, from: f32, finer: bool) -> f32

The same as previous_step(), but for normalized values. This is mostly useful for GUI widgets.
source§

fn next_normalized_step(&self, from: f32, finer: bool) -> f32

The same as next_step(), but for normalized values. This is mostly useful for GUI widgets.
source§

fn preview_modulated(&self, normalized_offset: f32) -> Self::Plain

Get the plain, unnormalized value for this parameter after polyphonic modulation has been applied. This is a convenience method for calling preview_plain() with unmodulated_normalized_value() + normalized_offset.`

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Any for Twhere T: Any,

§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,