pub struct PatchbayManager { /* private fields */ }Expand description
The main patchbay manager.
Coordinates all control and automation components. Runs in a dedicated thread at a configurable update rate.
Implementations§
Source§impl PatchbayManager
impl PatchbayManager
Sourcepub fn new(
config: PatchbayConfig,
command_queue: Arc<MpscQueue<SetParameter>>,
) -> Self
pub fn new( config: PatchbayConfig, command_queue: Arc<MpscQueue<SetParameter>>, ) -> Self
Create a new patchbay manager.
Sourcepub fn with_event_channel(self, tx: Sender<PatchbayEvent>) -> Self
pub fn with_event_channel(self, tx: Sender<PatchbayEvent>) -> Self
Set the event notification channel.
Sourcepub fn add_automaton<A: Automaton + 'static>(
&mut self,
id: impl Into<String>,
automaton: A,
) -> Result<(), &'static str>where
A::State: 'static,
pub fn add_automaton<A: Automaton + 'static>(
&mut self,
id: impl Into<String>,
automaton: A,
) -> Result<(), &'static str>where
A::State: 'static,
Sourcepub fn add_lfo(
&mut self,
id: impl Into<String>,
frequency: f64,
amplitude: f64,
offset: f64,
waveform: LfoWaveform,
) -> Result<(), &'static str>
pub fn add_lfo( &mut self, id: impl Into<String>, frequency: f64, amplitude: f64, offset: f64, waveform: LfoWaveform, ) -> Result<(), &'static str>
Sourcepub fn add_envelope(
&mut self,
id: impl Into<String>,
attack: f64,
decay: f64,
sustain: f64,
release: f64,
) -> Result<(), &'static str>
pub fn add_envelope( &mut self, id: impl Into<String>, attack: f64, decay: f64, sustain: f64, release: f64, ) -> Result<(), &'static str>
Add an envelope ADSR as an automaton.
§Errors
Returns Err if an automaton with the same ID already exists.
Sourcepub fn add_sequencer(
&mut self,
id: impl Into<String>,
steps: Vec<Step>,
) -> Result<(), &'static str>
pub fn add_sequencer( &mut self, id: impl Into<String>, steps: Vec<Step>, ) -> Result<(), &'static str>
Add a sequencer as an automaton.
§Errors
Returns Err if an automaton with the same ID already exists.
Sourcepub fn add_function<F>(
&mut self,
id: impl Into<String>,
generator: F,
) -> Result<(), &'static str>
pub fn add_function<F>( &mut self, id: impl Into<String>, generator: F, ) -> Result<(), &'static str>
Add a function-based automaton.
§Errors
Returns Err if an automaton with the same ID already exists.
Sourcepub fn reset_automaton<A: Automaton + 'static>(
&mut self,
id: &str,
) -> Result<(), &'static str>
pub fn reset_automaton<A: Automaton + 'static>( &mut self, id: &str, ) -> Result<(), &'static str>
Reset an automaton to its initial state.
§Errors
Returns Err if the automaton is not found or the type does not match.
Sourcepub fn remove_automaton(&mut self, id: &str) -> bool
pub fn remove_automaton(&mut self, id: &str) -> bool
Remove an automaton by ID.
Sourcepub fn add_servo(
&mut self,
id: impl Into<String>,
automaton_id: impl Into<String>,
target_node: NodeId,
target_param: impl Into<String>,
_mapping: ParameterMapping,
_min: f64,
_max: f64,
) -> Result<(), &'static str>
pub fn add_servo( &mut self, id: impl Into<String>, automaton_id: impl Into<String>, target_node: NodeId, target_param: impl Into<String>, _mapping: ParameterMapping, _min: f64, _max: f64, ) -> Result<(), &'static str>
Add a servo connecting an automaton to a parameter.
§Errors
Returns Err if the referenced automaton is not found.
Sourcepub fn add_lfo_servo(
&mut self,
id: impl Into<String>,
frequency: f64,
amplitude: f64,
offset: f64,
waveform: LfoWaveform,
target_node: NodeId,
target_param: impl Into<String>,
min: f64,
max: f64,
) -> Result<(), &'static str>
pub fn add_lfo_servo( &mut self, id: impl Into<String>, frequency: f64, amplitude: f64, offset: f64, waveform: LfoWaveform, target_node: NodeId, target_param: impl Into<String>, min: f64, max: f64, ) -> Result<(), &'static str>
Add an LFO servo (convenience method).
§Errors
Returns Err if an automaton with that ID already exists.
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 add_mapping(&mut self, mapping: Mapping)
pub fn add_mapping(&mut self, mapping: Mapping)
Add an event mapping.
Sourcepub fn add_midi_mapping(
&mut self,
controller: u8,
channel: Option<u8>,
target_node: NodeId,
target_param: impl Into<String>,
min: f32,
max: f32,
transform: Transform,
)
pub fn add_midi_mapping( &mut self, controller: u8, channel: Option<u8>, target_node: NodeId, target_param: impl Into<String>, min: f32, max: f32, transform: Transform, )
Add a MIDI CC mapping (convenience method).
Sourcepub fn add_osc_mapping(
&mut self,
address: &str,
target_node: NodeId,
target_param: impl Into<String>,
min: f32,
max: f32,
transform: Transform,
)
pub fn add_osc_mapping( &mut self, address: &str, target_node: NodeId, target_param: impl Into<String>, min: f32, max: f32, transform: Transform, )
Add an OSC address mapping (convenience method).
Sourcepub fn remove_mappings(&mut self, pattern: &EventPattern) -> usize
pub fn remove_mappings(&mut self, pattern: &EventPattern) -> usize
Remove all mappings matching a given pattern.
Returns the number of removed mappings.
Sourcepub fn clear_mappings(&mut self)
pub fn clear_mappings(&mut self)
Clear all mappings.
Sourcepub fn handle_event(&mut self, event: ControlEvent)
pub fn handle_event(&mut self, event: ControlEvent)
Handle an external event (MIDI/OSC).
Sourcepub fn handle_midi(&mut self, channel: u8, controller: u8, value: u8)
pub fn handle_midi(&mut self, channel: u8, controller: u8, value: u8)
Handle a MIDI message (convenience method).
Sourcepub fn handle_osc(&mut self, address: &str, args: Vec<f32>)
pub fn handle_osc(&mut self, address: &str, args: Vec<f32>)
Handle an OSC message (convenience method).
Sourcepub fn stats(&self) -> &PatchbayStats
pub fn stats(&self) -> &PatchbayStats
Return a reference to the runtime statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset the runtime statistics.
Sourcepub fn current_time(&self) -> f64
pub fn current_time(&self) -> f64
Return the current internal time in seconds.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check whether the manager is running.