Skip to main content

NodeRecord

Struct NodeRecord 

Source
pub struct NodeRecord {
    pub processor: Box<dyn DspNode>,
    pub inputs: [Option<NodeId>; 8],
    pub output_buffer: BufferId,
    pub params: ParamBlock,
}
Expand description

Graph-level node record. Stored in the arena.

Each node in the DSP graph is represented by a NodeRecord stored in the arena. The record contains the DSP processor, input connections, output buffer, and parameters.

§Structure

  • processor: The DSP implementation (boxed trait object)
  • inputs: Array of input connections (NodeId or None)
  • output_buffer: Buffer ID where this node writes output
  • params: Parameter block for smoothed parameter automation

§Memory Layout

The processor is heap-allocated (Box) at node creation time, not during audio processing. All other fields are inline in the arena slot.

§Example

use aether_core::node::{NodeRecord, DspNode};
use aether_core::buffer_pool::{BufferPool, BufferId};
use aether_core::param::ParamBlock;
use aether_core::{BUFFER_SIZE, MAX_INPUTS};

// Custom node implementation
struct Gain { gain: f32 }

impl DspNode for Gain {
    fn process(
        &mut self,
        inputs: &[Option<&[f32; BUFFER_SIZE]>; MAX_INPUTS],
        output: &mut [f32; BUFFER_SIZE],
        _params: &mut ParamBlock,
        _sample_rate: f32,
    ) {
        if let Some(input) = inputs[0] {
            for (i, out) in output.iter_mut().enumerate() {
                *out = input[i] * self.gain;
            }
        }
    }

    fn type_name(&self) -> &'static str {
        "Gain"
    }
}

// Create node record
let mut pool = BufferPool::new(10);
let buffer = pool.acquire().unwrap();
let processor = Box::new(Gain { gain: 0.5 });
let record = NodeRecord::new(processor, buffer);

§Lifecycle

  1. Creation: Allocated in arena when AddNode command is processed
  2. Processing: processor.process() called each audio block
  3. Removal: Dropped when RemoveNode command is processed

§See Also

Fields§

§processor: Box<dyn DspNode>

The DSP implementation (boxed, allocated at node creation time — not in RT).

§inputs: [Option<NodeId>; 8]

Input connections: each slot holds the NodeId of the upstream node.

§output_buffer: BufferId

The buffer this node writes its output into.

§params: ParamBlock

Parameter block for this node.

Implementations§

Source§

impl NodeRecord

Source

pub fn new(processor: Box<dyn DspNode>, output_buffer: BufferId) -> Self

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