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>
impl<'a, S: Sample> AuxInput<'a, S>
Sourcepub fn num_samples(&self) -> usize
pub fn num_samples(&self) -> usize
Number of samples in each channel.
Sourcepub fn num_channels(&self) -> usize
pub fn num_channels(&self) -> usize
Number of channels in this bus.
Sourcepub fn input(&self, index: usize) -> &[S]
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.
Sourcepub fn iter_inputs(&self) -> impl Iterator<Item = &[S]> + '_
pub fn iter_inputs(&self) -> impl Iterator<Item = &[S]> + '_
Iterate over all input channels.
Sourcepub fn rms(&self, channel: usize) -> S
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more