pub trait Param: Display + Debug + Sealed {
type Plain: PartialEq;
Show 21 methods
// Required methods
fn name(&self) -> &str;
fn unit(&self) -> &'static str;
fn poly_modulation_id(&self) -> Option<u32>;
fn modulated_plain_value(&self) -> Self::Plain;
fn modulated_normalized_value(&self) -> f32;
fn unmodulated_plain_value(&self) -> Self::Plain;
fn unmodulated_normalized_value(&self) -> f32;
fn default_plain_value(&self) -> Self::Plain;
fn step_count(&self) -> Option<usize>;
fn previous_step(&self, from: Self::Plain, finer: bool) -> Self::Plain;
fn next_step(&self, from: Self::Plain, finer: bool) -> Self::Plain;
fn normalized_value_to_string(
&self,
normalized: f32,
include_unit: bool
) -> String;
fn string_to_normalized_value(&self, string: &str) -> Option<f32>;
fn preview_normalized(&self, plain: Self::Plain) -> f32;
fn preview_plain(&self, normalized: f32) -> Self::Plain;
fn flags(&self) -> ParamFlags;
fn as_ptr(&self) -> ParamPtr;
// Provided methods
fn default_normalized_value(&self) -> f32 { ... }
fn previous_normalized_step(&self, from: f32, finer: bool) -> f32 { ... }
fn next_normalized_step(&self, from: f32, finer: bool) -> f32 { ... }
fn preview_modulated(&self, normalized_offset: f32) -> Self::Plain { ... }
}
Expand description
Describes a single parameter of any type. Most parameter implementations also have a field
called value
that and a field called smoothed
. The former stores the latest unsmoothed
value, and the latter can be used to access the smoother. These two fields should be used in DSP
code to either get the parameter’s current (smoothed) value. In UI code the getters from this
trait should be used instead.
Sealed
This trait cannot be implemented outside of NIH-plug itself. If you want to create new
abstractions around parameters, consider wrapping them in a struct instead. Then use the
#[nested(id_prefix = "foo")]
syntax from the Params
trait to reuse that wrapper in
multiple places.
Required Associated Types§
Required Methods§
sourcefn poly_modulation_id(&self) -> Option<u32>
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.
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.
sourcefn modulated_plain_value(&self) -> Self::Plain
fn modulated_plain_value(&self) -> Self::Plain
Get the unnormalized value for this parameter.
sourcefn modulated_normalized_value(&self) -> f32
fn modulated_normalized_value(&self) -> f32
Get the normalized [0, 1]
value for this parameter.
sourcefn unmodulated_plain_value(&self) -> Self::Plain
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.
sourcefn unmodulated_normalized_value(&self) -> f32
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.
sourcefn default_plain_value(&self) -> Self::Plain
fn default_plain_value(&self) -> Self::Plain
Get the unnormalized default value for this parameter.
sourcefn step_count(&self) -> Option<usize>
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.
sourcefn previous_step(&self, from: Self::Plain, finer: bool) -> Self::Plain
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.
If finer
is true, then the step size should be decreased if the parameter is continuous.
sourcefn next_step(&self, from: Self::Plain, finer: bool) -> Self::Plain
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.
If finer
is true, then the step size should be decreased if the parameter is continuous.
sourcefn normalized_value_to_string(
&self,
normalized: f32,
include_unit: bool
) -> String
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.
sourcefn string_to_normalized_value(&self, string: &str) -> Option<f32>
fn string_to_normalized_value(&self, string: &str) -> Option<f32>
Get the string representation for a normalized value. Used as part of the wrappers.
sourcefn preview_normalized(&self, plain: Self::Plain) -> f32
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.
sourcefn preview_plain(&self, normalized: f32) -> Self::Plain
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
).
sourcefn flags(&self) -> ParamFlags
fn flags(&self) -> ParamFlags
Flags to control the parameter’s behavior. See ParamFlags
.
Provided Methods§
sourcefn default_normalized_value(&self) -> f32
fn default_normalized_value(&self) -> f32
Get the normalized [0, 1]
default value for this parameter.
sourcefn previous_normalized_step(&self, from: f32, finer: bool) -> f32
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.
sourcefn next_normalized_step(&self, from: f32, finer: bool) -> f32
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.
sourcefn preview_modulated(&self, normalized_offset: f32) -> Self::Plain
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
.`