Skip to main content

PatchbayControl

Struct PatchbayControl 

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

The central patchbay controller.

Operates on the control thread (soft RT) and sends parameter commands to the audio thread via MpscQueue<SetParameter>.

§Operation modes

  • Sync (legacy): update(dt) walks all servos sequentially. Does not require tokio.
  • Async (recommended): automata run as tokio tasks through add_automaton_task(). Requires an active tokio runtime.

Implementations§

Source§

impl PatchbayControl

Source

pub fn new(command_queue: Arc<MpscQueue<SetParameter>>) -> Self

Create a new patchbay controller.

Source

pub fn add_mapping(&mut self, mapping: Mapping)

Add an event mapping.

Source

pub fn add_boxed_servo(&mut self, id: String, servo: BoxedServo)

Add a pre-constructed boxed servo.

Useful for automaton types not covered by add_lfo / add_envelope (e.g. sequencers, named functions).

Source

pub fn add_mapping_str( &mut self, pattern: &str, target_node: NodeId, target_param: &str, min: f32, max: f32, transform: Transform, ) -> Result<(), &'static str>

Add a mapping from string descriptions (convenient for scripting).

§Errors

Returns Err if the pattern string is malformed.

Source

pub fn add_servo<A: Automaton + 'static>(&mut self, servo: Servo<A>)

Add a servo (automaton → parameter bridge).

Source

pub fn add_lfo( &mut self, id: &str, frequency: f64, amplitude: f64, offset: f64, waveform: LfoWaveform, target_node: NodeId, target_param: &str, min: f64, max: f64, )

Add an LFO as a servo.

Source

pub fn add_envelope( &mut self, id: &str, attack: f64, decay: f64, sustain: f64, release: f64, target_node: NodeId, target_param: &str, min: f64, max: f64, )

Add an envelope ADSR as a servo.

Source

pub fn add_automaton_task<A: Automaton + 'static>( &mut self, id: &str, automaton: A, interval: Duration, target: (NodeId, String), range: (f64, f64), control: ControlStrategy, conflict: ConflictStrategy, )

Add an automaton as a green thread (tokio task).

Requires an active tokio runtime. Ports with async automata receive a PortCombiner that resolves UI ↔ automaton conflicts.

§Arguments
  • id — unique identifier
  • automaton — the automaton implementation
  • interval — update interval (e.g. 10 ms = 100 Hz)
  • target(node_id, param_name)
  • range(min, max) parameter range
  • control — control strategy
  • conflict — conflict resolution strategy
Source

pub fn add_lfo_task( &mut self, id: &str, frequency: f64, amplitude: f64, offset: f64, waveform: LfoWaveform, interval: Duration, target: (NodeId, String), range: (f64, f64), control: ControlStrategy, conflict: ConflictStrategy, )

Add an LFO as an async automaton task.

Source

pub fn add_envelope_task( &mut self, id: &str, attack: f64, decay: f64, sustain: f64, release: f64, interval: Duration, target: (NodeId, String), range: (f64, f64), control: ControlStrategy, conflict: ConflictStrategy, )

Add an envelope ADSR as an async automaton task.

Source

pub fn attach_sequencer( &mut self, tel_rx: CrossbeamReceiver<Telemetry>, sequencer: SnapshotSequencer, ) -> SequencerHandle

Attach a parameter-lock sequencer driven by audio-thread clock ticks.

Spawns a blocking tokio task that reads CLOCK_TICK telemetry and pushes returned parameter commands to the queue.

Returns a SequencerHandle for external control.

§Panics

Panics if a sequencer is already attached (call detach_sequencer() first).

Source

pub fn detach_sequencer(&mut self)

Detach the sequencer: abort its task and drop the handle.

Source

pub fn sequencer_handle(&self) -> Option<&SequencerHandle>

Get a reference to the sequencer handle, if attached.

Source

pub fn stop_all(&mut self)

Stop all async automata and the sequencer.

Source

pub fn handle_event(&mut self, event: ControlEvent)

Handle an external event (MIDI/OSC).

If a PortCombiner exists for the target port the event is routed there for conflict resolution; otherwise it is pushed directly to the command queue.

Source

pub fn update(&mut self, dt: f32)

Update synchronous servos.

This method is deprecated. For new projects use add_automaton_task() with green threads.

Source

pub fn get_combiner(&self, key: &str) -> Option<&PortCombinerHandle>

Get a combiner by key (format: "node_id:param_name").

Source

pub fn mappings(&self) -> &[Mapping]

Return all mappings.

Source

pub fn get_servo(&self, id: &str) -> Option<&dyn AnyServo>

Get a servo by ID.

Source

pub fn get_servo_mut(&mut self, id: &str) -> Option<&mut BoxedServo>

Get a mutable servo by ID.

Source

pub fn remove_servo(&mut self, id: &str) -> bool

Remove a servo by ID.

Source

pub fn clear(&mut self)

Clear all mappings, servos, and async automata.

Source

pub fn reset_time(&mut self)

Reset the internal clock to zero.

Source

pub fn current_time(&self) -> Time

Current internal time in seconds.

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V