Struct MixerBlock

Source
pub struct MixerBlock<S: Sample> { /* private fields */ }
Expand description

A channel-wise audio mixer that sums multiple sources per output channel.

Unlike MatrixMixerBlock which requires explicit gain setup, MixerBlock automatically groups inputs by channel and sums them. This is useful for combining multiple audio sources into a single stereo (or N-channel) output.

§Input Organization

Inputs are organized in groups, where each group represents one source’s contribution to all output channels. For stereo output with 3 sources:

  • Inputs 0, 1: Source A (L, R)
  • Inputs 2, 3: Source B (L, R)
  • Inputs 4, 5: Source C (L, R)

The mixer sums: Output L = A.L + B.L + C.L, Output R = A.R + B.R + C.R

Implementations§

Source§

impl<S: Sample> MixerBlock<S>

Source

pub fn new(num_sources: usize, num_channels: usize) -> Self

Create a new mixer for the given number of sources and output channels.

§Arguments
  • num_sources - Number of sources to mix (each provides all channels)
  • num_channels - Number of output channels (e.g., 2 for stereo)
§Panics

Panics if the total input count exceeds MAX_BLOCK_INPUTS (16).

Source

pub fn stereo(num_sources: usize) -> Self

Create a stereo mixer for the given number of sources.

Source

pub fn with_normalization(self, normalization: NormalizationStrategy) -> Self

Set the normalization strategy.

Source

pub fn num_sources(&self) -> usize

Returns the number of sources being mixed.

Source

pub fn num_channels(&self) -> usize

Returns the number of output channels.

Trait Implementations§

Source§

impl<S: Sample> Block<S> for MixerBlock<S>

Source§

fn process( &mut self, inputs: &[&[S]], outputs: &mut [&mut [S]], _modulation_values: &[S], _context: &DspContext, )

Process audio through this block. Read more
Source§

fn input_count(&self) -> usize

Returns the number of input ports this block accepts.
Source§

fn output_count(&self) -> usize

Returns the number of output ports this block produces.
Source§

fn modulation_outputs(&self) -> &[ModulationOutput]

Returns the modulation outputs this block provides. Read more
Source§

fn channel_config(&self) -> ChannelConfig

Returns how this block handles multi-channel audio. Read more
Source§

fn set_smoothing(&mut self, _sample_rate: f64, _ramp_time_ms: f64)

Configure smoothing time for parameter changes. Read more
Source§

impl<S: Sample> From<MixerBlock<S>> for BlockType<S>

Source§

fn from(block: MixerBlock<S>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<S> Freeze for MixerBlock<S>

§

impl<S> RefUnwindSafe for MixerBlock<S>
where S: RefUnwindSafe,

§

impl<S> Send for MixerBlock<S>

§

impl<S> Sync for MixerBlock<S>

§

impl<S> Unpin for MixerBlock<S>
where S: Unpin,

§

impl<S> UnwindSafe for MixerBlock<S>
where S: UnwindSafe,

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.