Skip to main content

ParamBlock

Struct ParamBlock 

Source
pub struct ParamBlock {
    pub params: [Param; 8],
    pub count: usize,
}
Expand description

A fixed-size block of parameters for a node.

Stores up to 8 parameters without heap allocation. Most DSP nodes need 1-4 parameters (gain, frequency, resonance, etc.), so 8 is sufficient for the vast majority of cases.

§Example

use aether_core::param::ParamBlock;

let mut params = ParamBlock::new();

// Add parameters
let gain_idx = params.add(0.75);      // Gain: 0.75
let cutoff_idx = params.add(1000.0);  // Cutoff: 1000 Hz
let res_idx = params.add(0.5);        // Resonance: 0.5

assert_eq!(params.count, 3);

// Access parameters
let gain = params.get(gain_idx);
assert_eq!(gain.current, 0.75);

// Modify parameters
params.get_mut(cutoff_idx).set_target(2000.0, 480);

// Tick all parameters
params.tick_all();

§Capacity

If you need more than 8 parameters, consider:

  • Splitting into multiple nodes
  • Using a custom parameter storage system
  • Increasing the array size (requires modifying the constant)

§See Also

  • Param - Individual parameter

Fields§

§params: [Param; 8]§count: usize

Implementations§

Source§

impl ParamBlock

Source

pub fn new() -> Self

Creates a new empty parameter block.

Initializes with zero parameters. Use add to add parameters.

§Example
use aether_core::param::ParamBlock;

let params = ParamBlock::new();
assert_eq!(params.count, 0);
Source

pub fn add(&mut self, value: f32) -> usize

Adds a parameter with the given initial value.

§Arguments
  • value - Initial parameter value
§Returns

The parameter’s index (0-7), used to access it later.

§Panics

Panics if the block is full (8 parameters already added).

§Example
use aether_core::param::ParamBlock;

let mut params = ParamBlock::new();

let gain_idx = params.add(0.5);
let freq_idx = params.add(440.0);

assert_eq!(gain_idx, 0);
assert_eq!(freq_idx, 1);
assert_eq!(params.count, 2);
Source

pub fn get(&self, idx: usize) -> &Param

Gets an immutable reference to a parameter.

§Arguments
  • idx - Parameter index (0-7)
§Returns

Reference to the parameter.

§Panics

Panics if idx is out of bounds.

§Example
use aether_core::param::ParamBlock;

let mut params = ParamBlock::new();
let gain_idx = params.add(0.75);

let gain = params.get(gain_idx);
assert_eq!(gain.current, 0.75);
Source

pub fn get_mut(&mut self, idx: usize) -> &mut Param

Gets a mutable reference to a parameter.

§Arguments
  • idx - Parameter index (0-7)
§Returns

Mutable reference to the parameter.

§Panics

Panics if idx is out of bounds.

§Example
use aether_core::param::ParamBlock;

let mut params = ParamBlock::new();
let cutoff_idx = params.add(1000.0);

// Schedule a ramp
params.get_mut(cutoff_idx).set_target(2000.0, 480);
Source

pub fn tick_all(&mut self)

Tick all active params by one sample.

Advances all parameters in the block by one sample. Call this once per sample in your node’s process() function.

§Example
use aether_core::param::ParamBlock;
use aether_core::BUFFER_SIZE;

let mut params = ParamBlock::new();
let gain_idx = params.add(0.0);
params.get_mut(gain_idx).set_target(1.0, BUFFER_SIZE as u32);

// Tick through buffer
for _ in 0..BUFFER_SIZE {
    let gain_value = params.get(gain_idx).current;
    // Use gain_value for processing...
    params.tick_all();
}

assert_eq!(params.get(gain_idx).current, 1.0);
§Performance

This function is highly optimized:

  • Inlined for zero call overhead
  • Only ticks active parameters (count)
  • Each tick is branch-free when not ramping

Trait Implementations§

Source§

impl Clone for ParamBlock

Source§

fn clone(&self) -> ParamBlock

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 ParamBlock

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ParamBlock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for ParamBlock

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.