audio seems fine now

This commit is contained in:
2025-10-26 18:57:04 -06:00
parent fea6800bea
commit 987cfd57d2
+2 -4
View File
@@ -69,7 +69,7 @@ impl AudioSystem {
mut each: impl FnMut(Vec<u8>) + Send + 'static,
) -> Result<(), Error> {
let mut encoder =
opus::Encoder::new(48_000, opus::Channels::Mono, opus::Application::Voip)?;
opus::Encoder::new(SAMPLE_RATE, opus::Channels::Mono, opus::Application::Voip)?;
let mut current_processor = AudioProcessor::default();
let mut output_buffer = Vec::new();
let processors = self.processors.clone();
@@ -78,16 +78,14 @@ impl AudioSystem {
if let Some(new_processor) = processors.take() {
current_processor = new_processor;
}
info!("recieved {} samples", frame.len());
current_processor.process(frame, &mut output_buffer);
if output_buffer.len() < PACKET_SAMPLES as usize {
return;
}
let remainder = output_buffer.split_off(PACKET_SAMPLES as usize);
let frame = replace(&mut output_buffer, remainder);
match encoder.encode_vec_float(&frame, frame.len() * 4) {
match encoder.encode_vec_float(&frame, frame.len() * 2) {
Ok(buf) => {
info!("encoded {} samples to {} bytes", frame.len(), buf.len());
each(buf);
}
Err(e) => {