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: u64Counts 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
impl Mixer
Sourcepub fn mix(&mut self, mic: &[i16], loopback: &[i16]) -> Vec<i16>
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.
Sourcepub fn mix_into(&mut self, mic: &[i16], loopback: &[i16], out: &mut Vec<i16>)
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.