Skip to main content

AuxInput

Struct AuxInput 

Source
pub struct AuxInput<'a, S: Sample = f32> { /* private fields */ }
Expand description

Immutable view of an auxiliary input bus.

Provides access to input channels for a single auxiliary bus (typically sidechain). Created via AuxiliaryBuffers::sidechain() or AuxiliaryBuffers::input().

§Type Parameter

S is the sample type, defaulting to f32.

§Example: Block-Based Analysis

if let Some(sc) = aux.sidechain() {
    // Calculate RMS of sidechain for keying
    let rms = sc.rms(0);

    // Or iterate over all channels
    for ch in sc.iter_inputs() {
        // Process channel...
    }
}

§Example: Sample-by-Sample Access

if let Some(sc) = aux.sidechain() {
    for i in 0..buffer.num_samples() {
        // .sample() returns S::ZERO if channel/index missing
        let key_l = sc.sample(0, i).to_f64().abs();
        let key_r = sc.sample(1, i).to_f64().abs();
        let key = (key_l + key_r) * 0.5;

        // Use for envelope follower, gate, ducker, etc.
    }
}

Implementations§

Source§

impl<'a, S: Sample> AuxInput<'a, S>

Source

pub fn num_samples(&self) -> usize

Number of samples in each channel.

Source

pub fn num_channels(&self) -> usize

Number of channels in this bus.

Source

pub fn input(&self, index: usize) -> &[S]

Get an input channel by index.

Returns an empty slice if the channel doesn’t exist. Matches Buffer::input() naming for API consistency.

Source

pub fn sample(&self, channel: usize, index: usize) -> S

Get a single sample from a channel.

Returns [S::ZERO] if the channel or sample index doesn’t exist. This is a convenience method for sample-by-sample processing.

§Example
// Instead of:
let sc = sidechain.input(0).get(i).copied().unwrap_or(S::ZERO);

// Use:
let sc = sidechain.sample(0, i);
Source

pub fn iter_inputs(&self) -> impl Iterator<Item = &[S]> + '_

Iterate over all input channels.

Source

pub fn rms(&self, channel: usize) -> S

Calculate the RMS (root mean square) level of a channel.

Returns zero if the channel doesn’t exist or is empty.

Source

pub fn peak(&self, channel: usize) -> S

Calculate the peak level of a channel.

Returns zero if the channel doesn’t exist or is empty.

Source

pub fn average(&self, channel: usize) -> S

Calculate the average absolute level of a channel.

Returns zero if the channel doesn’t exist or is empty.

Auto Trait Implementations§

§

impl<'a, S> Freeze for AuxInput<'a, S>

§

impl<'a, S> RefUnwindSafe for AuxInput<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for AuxInput<'a, S>

§

impl<'a, S> Sync for AuxInput<'a, S>

§

impl<'a, S> Unpin for AuxInput<'a, S>

§

impl<'a, S> UnwindSafe for AuxInput<'a, S>
where S: RefUnwindSafe,

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