Skip to main content

Command

Enum Command 

Source
pub enum Command {
    AddNode {
        id: NodeId,
    },
    RemoveNode {
        id: NodeId,
    },
    Connect {
        src: NodeId,
        dst: NodeId,
        slot: usize,
    },
    Disconnect {
        dst: NodeId,
        slot: usize,
    },
    UpdateParam {
        node: NodeId,
        param_index: usize,
        new_param: Param,
    },
    SetOutputNode {
        id: NodeId,
    },
    SetMute {
        muted: bool,
    },
    ClearGraph,
}
Expand description

All mutations the control thread can request.

Commands are sent from the control thread (UI, MIDI handler, etc.) to the real-time audio thread via an SPSC ring buffer. The audio thread drains commands at the start of each processing block.

§Design

  • Lock-free: Commands are sent via SPSC ring buffer (no locks)
  • Bounded: Max MAX_COMMANDS_PER_TICK processed per audio block
  • Clone: Commands are cloned when sent (cheap - no heap allocations)
  • Real-time safe: All command processing is bounded and allocation-free

§Example

use aether_core::command::Command;
use aether_core::arena::NodeId;

// Control thread sends commands
let cmd = Command::AddNode {
    id: NodeId { index: 0, generation: 1 }
};

// Audio thread receives and processes
match cmd {
    Command::AddNode { id } => {
        // Add node to graph
    }
    _ => {}
}

§Command Processing

Commands are processed in FIFO order. The audio thread processes up to MAX_COMMANDS_PER_TICK commands per block to bound latency impact.

§See Also

Variants§

§

AddNode

Add a new node to the graph.

The node must already exist in the arena. This command makes it visible to the scheduler for processing.

§Fields

  • id - Node ID in the arena

§Example

use aether_core::command::Command;
use aether_core::arena::NodeId;

let cmd = Command::AddNode {
    id: NodeId { index: 0, generation: 1 }
};

Fields

§

RemoveNode

Remove a node from the graph and release its buffer.

The node is removed from the processing order and its output buffer is returned to the pool. All connections to/from this node are automatically disconnected.

§Fields

  • id - Node ID to remove

§Example

use aether_core::command::Command;
use aether_core::arena::NodeId;

let cmd = Command::RemoveNode {
    id: NodeId { index: 0, generation: 1 }
};

Fields

§

Connect

Connect output of src to input slot slot of dst.

Creates an audio connection between two nodes. The output of src will be routed to input slot slot of dst. If the slot is already connected, the old connection is replaced.

§Fields

  • src - Source node ID (output)
  • dst - Destination node ID (input)
  • slot - Input slot index (0 to MAX_INPUTS-1)

§Example

use aether_core::command::Command;
use aether_core::arena::NodeId;

let osc = NodeId { index: 0, generation: 1 };
let filter = NodeId { index: 1, generation: 1 };

// Connect oscillator output to filter input slot 0
let cmd = Command::Connect {
    src: osc,
    dst: filter,
    slot: 0,
};

Fields

§slot: usize
§

Disconnect

Disconnect input slot slot of dst.

Removes the connection to the specified input slot. The slot will receive silence (None) in subsequent processing.

§Fields

  • dst - Destination node ID
  • slot - Input slot index to disconnect

§Example

use aether_core::command::Command;
use aether_core::arena::NodeId;

let filter = NodeId { index: 1, generation: 1 };

// Disconnect input slot 0
let cmd = Command::Disconnect {
    dst: filter,
    slot: 0,
};

Fields

§slot: usize
§

UpdateParam

Update a parameter with a new smoothed value.

Changes a node parameter with automatic smoothing to avoid clicks. The parameter will ramp from its current value to the new target over the configured smoothing time.

§Fields

  • node - Node ID to update
  • param_index - Parameter index (0-based)
  • new_param - New parameter with target value and smoothing

§Example

use aether_core::command::Command;
use aether_core::arena::NodeId;
use aether_core::param::Param;

let filter = NodeId { index: 1, generation: 1 };

// Update filter cutoff to 1000 Hz
let cmd = Command::UpdateParam {
    node: filter,
    param_index: 0,
    new_param: Param::new(1000.0),
};

Fields

§node: NodeId
§param_index: usize
§new_param: Param
§

SetOutputNode

Swap the output node.

Designates a new node as the graph output. The output node’s buffer is copied to the final output buffer each processing block.

§Fields

  • id - Node ID to use as output

§Example

use aether_core::command::Command;
use aether_core::arena::NodeId;

let master = NodeId { index: 5, generation: 1 };

let cmd = Command::SetOutputNode { id: master };

Fields

§

SetMute

Mute / unmute all audio output.

When muted, the output buffer is filled with silence regardless of graph processing. Processing continues normally - only the final output is silenced.

§Fields

  • muted - true to mute, false to unmute

§Example

use aether_core::command::Command;

// Mute output
let cmd = Command::SetMute { muted: true };

// Unmute output
let cmd = Command::SetMute { muted: false };

Fields

§muted: bool
§

ClearGraph

Remove all nodes and edges — silence the graph.

Clears the entire graph, removing all nodes and connections. All buffers are released back to the pool. The graph is left in an empty state.

§Example

use aether_core::command::Command;

let cmd = Command::ClearGraph;

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.