Skip to main content

IntParam

Struct IntParam 

Source
pub struct IntParam {
    pub smoothed: Smoother<i32>,
    /* private fields */
}
Expand description

A discrete integer parameter that’s stored unnormalized. The range is used for the normalization process.

Fields§

§smoothed: Smoother<i32>

An optional smoother that will automatically interpolate between the new automation values set by the host.

Implementations§

Source§

impl IntParam

Source

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

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

Source

pub fn value(&self) -> i32

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

Source

pub fn range(&self) -> IntRange

The range of valid plain values for this parameter.

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_smoother(self, style: SmoothingStyle) -> Self

Set up a smoother that can gradually interpolate changes made to this parameter, preventing clicks and zipper noises.

Source

pub fn with_callback(self, callback: Arc<dyn Fn(i32) + 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_unit(self, unit: &'static str) -> Self

Display a unit when rendering this parameter to a string. Appended after the value_to_string function if that is also set. nice-plug will not automatically add a space before the unit.

Source

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

Use a custom conversion function to convert the plain, unnormalized value to a string.

Source

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

Use a custom conversion function to convert from a string to a plain, unnormalized 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.

The input string may or may not contain the unit, so you will need to be able to handle that.

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 nice-plug’s generic UI widgets.

Trait Implementations§

Source§

impl Debug for IntParam

Source§

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

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

impl Display for IntParam

Source§

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

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

impl InternalParamMut for IntParam

Source§

unsafe fn _internal_set_plain_value(&self, plain: Self::Plain) -> bool

Set this parameter based on a plain, unnormalized value. This does not snap to step sizes for continuous parameters (i.e. FloatParam). If modulate_value() has previously been called with a non zero value then this offset is taken into account to form the effective value. Read more
Source§

unsafe fn _internal_set_normalized_value(&self, normalized: f32) -> bool

Set this parameter based on a normalized value. The normalized value will be snapped to the step size for continuous parameters (i.e. FloatParam). If modulate_value() has previously been called with a non zero value then this offset is taken into account to form the effective value. Read more
Source§

unsafe fn _internal_modulate_value(&self, modulation_offset: f32) -> bool

Add a modulation offset to the value’s unmodulated value. This value sticks until this function is called again with a 0.0 value. Out of bound values will be clamped to the parameter’s range. The normalized value will be snapped to the step size for continuous parameters (i.e. FloatParam). Read more
Source§

unsafe fn _internal_update_smoother(&self, sample_rate: f32, reset: bool)

Update the smoother state to point to the current value. Also used when initializing and restoring a plugin so everything is in sync. In that case the smoother should completely reset to the current value. Read more
Source§

impl Param for IntParam

Source§

type Plain = i32

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T, U> Into<U> for T
where 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.

Source§

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

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.