Skip to main content

PatchbayEngine

Struct PatchbayEngine 

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

High-level orchestrator for the patchbay system.

Manages automaton green threads, port combiners with conflict resolution strategies, event mappings, and graceful shutdown.

All automaton management is delegated to PatchbayControl; this struct provides a simplified API and ensures proper cleanup.

Implementations§

Source§

impl PatchbayEngine

Source

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

Create a new engine on the current tokio runtime.

Requires an active tokio runtime (e.g. #[tokio::main]). Panics if tokio::runtime::Handle::try_current() fails.

Source

pub fn add_automaton<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 with PortCombiner.

Source

pub fn add_lfo( &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 a green thread.

Source

pub fn add_envelope( &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 ADSR envelope as a green thread.

Source

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

Add an event mapping (MIDI/OSC → parameter).

Source

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

Route an external event through active mappings.

If a PortCombiner exists for the target parameter, the value is routed there for conflict resolution. Otherwise it goes directly to the command queue.

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.

See PatchbayControl::attach_sequencer for details.

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(&mut self)

Stop all automaton green threads and clear mappings.

Source

pub fn control(&self) -> &PatchbayControl

Borrow the inner control.

Source

pub fn control_mut(&mut self) -> &mut PatchbayControl

Mutably borrow the inner control.

Trait Implementations§

Source§

impl Drop for PatchbayEngine

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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