ParamF32

Struct ParamF32 

Source
pub struct ParamF32<const MAX_BLOCKSIZE: usize> { /* private fields */ }
Expand description

An auto-smoothed parameter with an f32 value.

Implementations§

Source§

impl<const MAX_BLOCKSIZE: usize> ParamF32<MAX_BLOCKSIZE>

Source

pub fn from_value( value: f32, min: f32, max: f32, gradient: Gradient, unit: Unit, smooth_secs: Seconds, sample_rate: SampleRate, ) -> (Self, ParamF32Handle)

Create a Parameter/Handle pair from its (de-normalized) value.

  • value - The initial (de-normalized) value of the parameter.
  • min - The minimum (de-normalized) value of the parameter.
  • max - The maximum (de-normalized) value of the parameter.
  • gradient - The Gradient mapping used when converting from the normalized value in the range [0.0, 1.0] to the desired value. If this parameter deals with decibels, you may use ParamF32::DEFAULT_SMOOTH_SECS as a good default.
  • unit - The Unit that signifies how the value displayed to the end user should differ from the actual value used in DSP.
  • smooth_secs: The period of the low-pass parameter smoothing filter (for declicking). You may use ParamF32::DEFAULT_SMOOTH_SECS as a good default.
  • sample_rate: The sample rate of this process. This is used for the low-pass parameter smoothing filter.
Source

pub fn from_normalized( normalized: f32, min_value: f32, max_value: f32, gradient: Gradient, unit: Unit, smooth_secs: Seconds, sample_rate: SampleRate, ) -> (Self, ParamF32Handle)

Create a Parameter/Handle pair from its normalized value in the range [0.0, 1.0].

  • value - The initial normalized value of the parameter in the range [0.0, 1.0].
  • min - The minimum (de-normalized) value of the parameter.
  • max - The maximum (de-normalized) value of the parameter.
  • gradient - The Gradient mapping used when converting from the normalized value in the range [0.0, 1.0] to the desired value. If this parameter deals with decibels, you may use ParamF32::DEFAULT_SMOOTH_SECS as a good default.
  • unit - The Unit that signifies how the value displayed to the end user should differ from the actual value used in DSP.
  • smooth_secs: The period of the low-pass parameter smoothing filter (for declicking). You may use ParamF32::DEFAULT_SMOOTH_SECS as a good default.
  • sample_rate: The sample rate of this process. This is used for the low-pass parameter smoothing filter.
Source

pub fn set_value(&mut self, value: f32)

Set the (de-normalized) value of this parameter.

Source

pub fn set_normalized(&mut self, normalized: f32)

Set the normalized value of this parameter in the range [0.0, 1.0].

Source

pub fn reset_from_value(&mut self, value: f32)

Reset this parameter (without any smoothing) to the given (de-normalized) value.

Source

pub fn reset_from_normalized(&mut self, normalized: f32)

Reset this parameter (without any smoothing) to the given normalized value in the range [0.0, 1.0].

Source

pub fn reset(&mut self)

Reset the internal smoothing buffer.

Source

pub fn smoothed(&mut self, frames: usize) -> SmoothOutputF32<'_, MAX_BLOCKSIZE>

Get the smoothed buffer of values for use in DSP.

Source

pub fn set_sample_rate(&mut self, sample_rate: SampleRate)

Update the sample rate (used for the parameter smoothing LPF).

Source

pub fn min(&self) -> f32

The minimum value of this parameter.

Source

pub fn max(&self) -> f32

The maximum value of this parameter.

Source

pub fn gradient(&self) -> Gradient

The Gradient mapping used when converting from the normalized value in the range [0.0, 1.0] to the desired value.

Source

pub fn unit(&self) -> Unit

The Unit that signifies how the value displayed to the end user should differ from the actual value used in DSP.

Source

pub fn value_to_normalized(&self, value: f32) -> f32

Convert the given value to the corresponding normalized range [0.0, 1.0] of this parameter.

Source

pub fn normalized_to_value(&self, normalized: f32) -> f32

Convert the given normalized value in the range [0.0, 1.0] into the corresponding value of this parameter.

Source

pub fn normalized(&self) -> f32

The current normalized value in the range [0.0, 1.0]. This is only meant for communicating with the host. This is not meant to be used to retrieve the latest value for DSP. To get the latest value for DSP please use ParamF32::smoothed() instead.

Please note that this should be called after calling ParamF32::smoothed() if you need the latest value from the corresponding ParamF32Handle, otherwise this may not return the latest value.

Source

pub fn shared_normalized(&self) -> Arc<AtomicF32>

Get the shared normalized float value.

This can be useful to integrate with various plugin APIs.

Auto Trait Implementations§

§

impl<const MAX_BLOCKSIZE: usize> Freeze for ParamF32<MAX_BLOCKSIZE>

§

impl<const MAX_BLOCKSIZE: usize> RefUnwindSafe for ParamF32<MAX_BLOCKSIZE>

§

impl<const MAX_BLOCKSIZE: usize> Send for ParamF32<MAX_BLOCKSIZE>

§

impl<const MAX_BLOCKSIZE: usize> Sync for ParamF32<MAX_BLOCKSIZE>

§

impl<const MAX_BLOCKSIZE: usize> Unpin for ParamF32<MAX_BLOCKSIZE>

§

impl<const MAX_BLOCKSIZE: usize> UnwindSafe for ParamF32<MAX_BLOCKSIZE>

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, 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.