Skip to main content

VoiceInput

Struct VoiceInput 

Source
pub struct VoiceInput { /* private fields */ }
Expand description

In-graph voice controller: the per-voice control-signal source.

This GraphModule is inserted into every voice patch and outputs the per-voice voct, gate, trigger, and velocity signals. Values come from a shared VoiceControl handle written by PolyPatch (or any external driver), so allocator state genuinely reaches the DSP graph.

The trigger output is a proper one-shot pulse measured in samples: a rising edge on the control handle’s trigger request emits 5 V for TRIGGER_S seconds’ worth of samples, regardless of how briefly the request was asserted.

The name is kept as VoiceInput for API continuity; conceptually it is the voice controller.

Implementations§

Source§

impl VoiceInput

Source

pub fn new() -> Self

Create a new voice input backed by a fresh, private control handle.

Source

pub fn with_control(control: Arc<VoiceControl>, sample_rate: f64) -> Self

Create a voice input driven by a shared control handle at a given sample rate (used by PolyPatch so it can write values from the outside).

Source

pub fn control(&self) -> &Arc<VoiceControl>

The shared control handle this input reads from.

Source

pub fn set_from_voice(&mut self, voice: &Voice)

Copy the allocator voice’s control values into the shared handle.

Source

pub fn set_voct(&mut self, voct: f64)

Set V/Oct directly (writes the shared handle).

Source

pub fn set_gate(&mut self, gate: f64)

Set gate directly.

Source

pub fn set_trigger(&mut self, trigger: f64)

Set trigger request directly.

Source

pub fn set_velocity(&mut self, velocity: f64)

Set velocity directly.

Source

pub fn voct(&self) -> f64

Current V/Oct value (reads the shared handle).

Source

pub fn gate(&self) -> f64

Current gate value.

Source

pub fn trigger(&self) -> f64

Current trigger request value.

Source

pub fn velocity(&self) -> f64

Current velocity value.

Trait Implementations§

Source§

impl Default for VoiceInput

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl GraphModule for VoiceInput

Source§

fn port_spec(&self) -> &PortSpec

Returns the module’s port specification
Source§

fn tick(&mut self, _inputs: &PortValues, outputs: &mut PortValues)

Process one sample given port values
Source§

fn reset(&mut self)

Reset internal state
Source§

fn set_sample_rate(&mut self, sample_rate: f64)

Set sample rate
Source§

fn type_id(&self) -> &'static str

Get module type identifier for serialization
Source§

fn process_block( &mut self, inputs: &BlockPortValues, outputs: &mut BlockPortValues, frames: usize, )

Process a block of samples (optional optimization). Read more
Source§

fn breaks_feedback_cycle(&self) -> bool

Whether this module breaks a feedback cycle in the patch graph. Read more
Source§

fn params(&self) -> &[ParamDef]

Get parameter definitions for UI binding. Read more
Source§

fn get_param(&self, _id: ParamId) -> Option<f64>

Get a parameter value. Read more
Source§

fn set_param(&mut self, _id: ParamId, _value: f64)

Set a parameter value. Read more
Source§

fn serialize_state(&self) -> Option<Value>

Available on crate feature alloc only.
Serialize module state (alloc feature only)
Source§

fn deserialize_state(&mut self, _state: &Value) -> Result<(), String>

Available on crate feature alloc only.
Deserialize module state (alloc feature only)
Source§

fn introspect(&self) -> Option<&dyn ModuleIntrospection>

Available on crate feature alloc only.
Downcast this module to its ModuleIntrospection view, if it exposes one. Read more
Source§

fn introspect_mut(&mut self) -> Option<&mut dyn ModuleIntrospection>

Available on crate feature alloc only.
Mutable companion to introspect, used to set internal parameters.

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