Skip to main content

PotHead

Struct PotHead 

Source
pub struct PotHead<TIn: 'static, TOut: 'static = TIn> { /* private fields */ }

Implementations§

Source§

impl<TIn, TOut> PotHead<TIn, TOut>
where TIn: 'static + Copy + PartialOrd + AsPrimitive<f32>, TOut: 'static + Copy + PartialOrd + AsPrimitive<f32>, f32: AsPrimitive<TOut>,

Source

pub fn new(config: &'static Config<TIn, TOut>) -> Result<Self, ConfigError>

Source

pub fn config(&self) -> &Config<TIn, TOut>

Source

pub fn process(&mut self, input: TIn) -> TOut

Source

pub fn physical_position(&self) -> f32

Returns the current physical input position in normalized 0.0..1.0 range. Useful for UI display when grab mode is active.

This always reflects where the pot physically is (after normalize→filter→curve→hysteresis), but BEFORE virtual modifications like snap zones and grab mode logic.

Source

pub fn current_output(&self) -> f32

Returns the current output value in normalized 0.0..1.0 range without updating state. Useful for reading the locked virtual value in grab mode.

Source

pub fn is_waiting_for_grab(&self) -> bool

Returns true if grab mode is active but not yet grabbed. When true, physical_position() != current_output()

Source

pub fn set_virtual_value(&mut self, value: TOut)

Set the virtual parameter value (e.g., after preset change or automation). This unlocks grab mode, requiring the pot to be grabbed again.

value is in the same output space as process() returns.

When switching which parameter a physical pot controls, use attach instead — it also seeds the filter to prevent false grabs on reactivation.

Source

pub fn attach(&mut self, current_input: TIn)

Attach a physical pot to this parameter.

Call this when switching which parameter the pot controls. Seeds the EMA filter to the current physical position so grab detection starts from a clean state — no cold-start ramp that PassThrough mode could misread as physical movement.

If the parameter value has changed since it was last active (e.g. after a preset load), call set_virtual_value before attach.

Pair with detach on the outgoing parameter.

Source

pub fn detach(&mut self)

Detach the physical pot from this parameter.

If the pot was grabbed (actively tracking this parameter), snapshots the current physical position into virtual_value so the user must pass through it again to re-grab on the next attach. If the pot was not yet grabbed (still waiting to cross the stored value), virtual_value is left unchanged — it already holds the correct stored parameter value and overwriting it with the physical position would corrupt it.

Safe to call unconditionally when switching pot control to another parameter. Pair with attach on the incoming parameter.

Auto Trait Implementations§

§

impl<TIn, TOut> Freeze for PotHead<TIn, TOut>

§

impl<TIn, TOut> RefUnwindSafe for PotHead<TIn, TOut>
where TIn: RefUnwindSafe, TOut: RefUnwindSafe,

§

impl<TIn, TOut> Send for PotHead<TIn, TOut>
where TIn: Sync, TOut: Sync,

§

impl<TIn, TOut> Sync for PotHead<TIn, TOut>
where TIn: Sync, TOut: Sync,

§

impl<TIn, TOut> Unpin for PotHead<TIn, TOut>

§

impl<TIn, TOut> UnsafeUnpin for PotHead<TIn, TOut>

§

impl<TIn, TOut> UnwindSafe for PotHead<TIn, TOut>
where TIn: RefUnwindSafe, TOut: RefUnwindSafe,

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.