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
impl PatchbayEngine
Sourcepub fn new(command_queue: Arc<MpscQueue<SetParameter>>) -> Self
pub fn new(command_queue: Arc<MpscQueue<SetParameter>>) -> 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.
Sourcepub fn add_automaton<A: Automaton + 'static>(
&mut self,
id: &str,
automaton: A,
interval: Duration,
target: (NodeId, String),
range: (f64, f64),
control: ControlStrategy,
conflict: ConflictStrategy,
)
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.
Sourcepub 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,
)
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.
Sourcepub 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,
)
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.
Sourcepub fn add_mapping(&mut self, mapping: Mapping)
pub fn add_mapping(&mut self, mapping: Mapping)
Add an event mapping (MIDI/OSC → parameter).
Sourcepub fn handle_event(&mut self, event: ControlEvent)
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.
Sourcepub fn attach_sequencer(
&mut self,
tel_rx: CrossbeamReceiver<Telemetry>,
sequencer: SnapshotSequencer,
) -> SequencerHandle
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.
Sourcepub fn detach_sequencer(&mut self)
pub fn detach_sequencer(&mut self)
Detach the sequencer: abort its task and drop the handle.
Sourcepub fn sequencer_handle(&self) -> Option<&SequencerHandle>
pub fn sequencer_handle(&self) -> Option<&SequencerHandle>
Get a reference to the sequencer handle, if attached.
Sourcepub fn control(&self) -> &PatchbayControl
pub fn control(&self) -> &PatchbayControl
Borrow the inner control.
Sourcepub fn control_mut(&mut self) -> &mut PatchbayControl
pub fn control_mut(&mut self) -> &mut PatchbayControl
Mutably borrow the inner control.