Skip to main content

PatchbayManager

Struct PatchbayManager 

Source
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

Source

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

Create a new patchbay manager.

Source

pub fn with_event_channel(self, tx: Sender<PatchbayEvent>) -> Self

Set the event notification channel.

Source

pub fn add_automaton<A: Automaton + 'static>( &mut self, id: impl Into<String>, automaton: A, ) -> Result<(), &'static str>
where A::State: 'static,

Add an automaton.

§Errors

Returns Err if an automaton with the same ID already exists.

Source

pub fn add_lfo( &mut self, id: impl Into<String>, frequency: f64, amplitude: f64, offset: f64, waveform: LfoWaveform, ) -> Result<(), &'static str>

Add an LFO as an automaton.

§Errors

Returns Err if an automaton with the same ID already exists.

Source

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.

Source

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.

Source

pub fn add_function<F>( &mut self, id: impl Into<String>, generator: F, ) -> Result<(), &'static str>
where F: Fn(f64) -> f64 + Send + Sync + 'static,

Add a function-based automaton.

§Errors

Returns Err if an automaton with the same ID already exists.

Source

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.

Source

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

Remove an automaton by ID.

Source

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.

Source

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.

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 add_mapping(&mut self, mapping: Mapping)

Add an event mapping.

Source

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).

Source

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).

Source

pub fn remove_mappings(&mut self, pattern: &EventPattern) -> usize

Remove all mappings matching a given pattern.

Returns the number of removed mappings.

Source

pub fn clear_mappings(&mut self)

Clear all mappings.

Source

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

Handle an external event (MIDI/OSC).

Source

pub fn handle_midi(&mut self, channel: u8, controller: u8, value: u8)

Handle a MIDI message (convenience method).

Source

pub fn handle_osc(&mut self, address: &str, args: Vec<f32>)

Handle an OSC message (convenience method).

Source

pub fn start(&mut self) -> Result<(), &'static str>

Start the manager in a separate thread.

§Errors

Returns Err if the manager is already running.

Source

pub fn stop(&mut self)

Stop the manager.

Source

pub fn stats(&self) -> &PatchbayStats

Return a reference to the runtime statistics.

Source

pub fn reset_stats(&mut self)

Reset the runtime statistics.

Source

pub fn current_time(&self) -> f64

Return the current internal time in seconds.

Source

pub fn is_running(&self) -> bool

Check whether the manager is running.

Trait Implementations§

Source§

impl Drop for PatchbayManager

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