Struct nih_plug::context::gui::ParamSetter
source · pub struct ParamSetter<'a> {
pub raw_context: &'a dyn GuiContext,
}
Expand description
A convenience helper for setting parameter values. Any changes made here will be broadcasted to
the host and reflected in the plugin’s Params
object. These
functions should only be called from the main thread.
Fields§
§raw_context: &'a dyn GuiContext
Implementations§
source§impl<'a> ParamSetter<'a>
impl<'a> ParamSetter<'a>
pub fn new(context: &'a dyn GuiContext) -> Self
sourcepub fn begin_set_parameter<P: Param>(&self, param: &P)
pub fn begin_set_parameter<P: Param>(&self, param: &P)
Inform the host that you will start automating a parameter. This needs to be called before
calling set_parameter()
for the specified parameter.
sourcepub fn set_parameter<P: Param>(&self, param: &P, value: P::Plain)
pub fn set_parameter<P: Param>(&self, param: &P, value: P::Plain)
Set a parameter to the specified parameter value. You will need to call
begin_set_parameter()
before and
end_set_parameter()
after calling this so the host can
properly record automation for the parameter. This can be called multiple times in a row
before calling end_set_parameter()
, for instance when moving
a slider around.
This function assumes you’re already calling this from a GUI thread. Calling any of these functions from any other thread may result in unexpected behavior.
sourcepub fn set_parameter_normalized<P: Param>(&self, param: &P, normalized: f32)
pub fn set_parameter_normalized<P: Param>(&self, param: &P, normalized: f32)
Set a parameter to an already normalized value. Works exactly the same as
set_parameter()
and needs to follow the same rules, but this may
be useful when implementing a GUI.
This does not perform any snapping. Consider converting the normalized value to a plain
value and setting that with set_parameter()
instead so the
normalized value known to the host matches param.normalized_value()
.
sourcepub fn end_set_parameter<P: Param>(&self, param: &P)
pub fn end_set_parameter<P: Param>(&self, param: &P)
Inform the host that you are done automating a parameter. This needs to be called after one
or more set_parameter()
calls for a parameter so the host knows
the automation gesture has finished.