pub struct AudioMixer {
channels: u8,
mic_queue: VecDeque<f32>,
sys_audio_queue: VecDeque<f32>,
}Expand description
Two-source audio mixer. Both inputs must use the same sample rate + channel count as the configured output.
Fields§
§channels: u8§mic_queue: VecDeque<f32>§sys_audio_queue: VecDeque<f32>Implementations§
Source§impl AudioMixer
impl AudioMixer
Sourcepub fn new(channels: u8) -> Result<Self, MixerError>
pub fn new(channels: u8) -> Result<Self, MixerError>
Construct a new mixer for the given channel count.
§Errors
Returns MixerError::ZeroChannels if channels == 0.
Sourcepub fn push_mic(&mut self, samples: &[f32]) -> Result<(), MixerError>
pub fn push_mic(&mut self, samples: &[f32]) -> Result<(), MixerError>
Push interleaved F32 mic samples. samples.len() must be a
multiple of channel count.
§Errors
Returns MixerError::UnalignedSamples on misalignment.
Sourcepub fn push_sys_audio(&mut self, samples: &[f32]) -> Result<(), MixerError>
pub fn push_sys_audio(&mut self, samples: &[f32]) -> Result<(), MixerError>
Push interleaved F32 system-audio samples. Same alignment
contract as Self::push_mic.
§Errors
Returns MixerError::UnalignedSamples on misalignment.
Sourcepub fn pull(&mut self) -> Vec<f32>
pub fn pull(&mut self) -> Vec<f32>
Drain whatever’s currently mixable + return the merged interleaved samples.
Length = min(mic_avail, sys_avail) when both are active;
mic_avail when only mic is pushing; sys_avail when only
system-audio is pushing; 0 when neither has anything.
Always returns a sample count that’s a multiple of channel count.
Sourcepub fn mic_queued(&self) -> usize
pub fn mic_queued(&self) -> usize
Bytes currently queued from the mic input (sample count, not byte count — multiply by 4 for F32 byte length).
Sourcepub fn sys_audio_queued(&self) -> usize
pub fn sys_audio_queued(&self) -> usize
Bytes currently queued from the system-audio input.