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
impl PatchbayControl
Sourcepub fn new(command_queue: Arc<MpscQueue<SetParameter>>) -> Self
pub fn new(command_queue: Arc<MpscQueue<SetParameter>>) -> Self
Create a new patchbay controller.
Sourcepub fn add_mapping(&mut self, mapping: Mapping)
pub fn add_mapping(&mut self, mapping: Mapping)
Add an event mapping.
Sourcepub fn add_boxed_servo(&mut self, id: String, servo: BoxedServo)
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).
Sourcepub fn add_mapping_str(
&mut self,
pattern: &str,
target_node: NodeId,
target_param: &str,
min: f32,
max: f32,
transform: Transform,
) -> Result<(), &'static str>
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.
Sourcepub fn add_servo<A: Automaton + 'static>(&mut self, servo: Servo<A>)
pub fn add_servo<A: Automaton + 'static>(&mut self, servo: Servo<A>)
Add a servo (automaton → parameter bridge).
Sourcepub 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,
)
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.
Sourcepub 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,
)
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.
Sourcepub 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,
)
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 identifierautomaton— the automaton implementationinterval— update interval (e.g. 10 ms = 100 Hz)target—(node_id, param_name)range—(min, max)parameter rangecontrol— control strategyconflict— conflict resolution strategy
Sourcepub 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,
)
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.
Sourcepub 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,
)
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.
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.
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).
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 handle_event(&mut self, event: ControlEvent)
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.
Sourcepub fn update(&mut self, dt: f32)
pub fn update(&mut self, dt: f32)
Update synchronous servos.
This method is deprecated. For new projects use add_automaton_task()
with green threads.
Sourcepub fn get_combiner(&self, key: &str) -> Option<&PortCombinerHandle>
pub fn get_combiner(&self, key: &str) -> Option<&PortCombinerHandle>
Get a combiner by key (format: "node_id:param_name").
Sourcepub fn get_servo_mut(&mut self, id: &str) -> Option<&mut BoxedServo>
pub fn get_servo_mut(&mut self, id: &str) -> Option<&mut BoxedServo>
Get a mutable servo by ID.
Sourcepub fn remove_servo(&mut self, id: &str) -> bool
pub fn remove_servo(&mut self, id: &str) -> bool
Remove a servo by ID.
Sourcepub fn reset_time(&mut self)
pub fn reset_time(&mut self)
Reset the internal clock to zero.
Sourcepub fn current_time(&self) -> Time
pub fn current_time(&self) -> Time
Current internal time in seconds.