Skip to main content

Mixer

Struct Mixer 

Source
pub struct Mixer {
    pub mic_gain: f32,
    pub loopback_gain: f32,
    pub drift_frames: u64,
    /* private fields */
}

Fields§

§mic_gain: f32§loopback_gain: f32§drift_frames: u64

Counts iterations where mic vs loopback length difference exceeded HOLD_SAMPLES. Callers can read this to decide whether to nudge the APM stream delay (drift > 250ms beyond seed risks AEC3 divergence — see APM_PLAYBACK_DELAY_MS).

Implementations§

Source§

impl Mixer

Source

pub fn mix(&mut self, mic: &[i16], loopback: &[i16]) -> Vec<i16>

Allocate a fresh output buffer. Convenience for tests; the hot capture loop should use mix_into to recycle a Vec<i16>. #[allow(dead_code)] because production callers always use mix_into — keeping the alloc’ing helper for test ergonomics.

Source

pub fn mix_into(&mut self, mic: &[i16], loopback: &[i16], out: &mut Vec<i16>)

Mix mic + loopback into the caller-supplied out buffer. Resizes out to max(mic.len(), loopback.len()) and writes per-sample (mic[i]*g_mic + loopback[i]*g_lp) with sample-and-hold padding on the shorter side. Reusing out between calls is the entire point — the audio thread runs at 10Hz and cannot afford a 6.4KB alloc per tick.

Trait Implementations§

Source§

impl Default for Mixer

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Mixer

§

impl RefUnwindSafe for Mixer

§

impl Send for Mixer

§

impl Sync for Mixer

§

impl Unpin for Mixer

§

impl UnsafeUnpin for Mixer

§

impl UnwindSafe for Mixer

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.