From 4496316f07c2457f7f4e486efc5f24677438fcf5 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Sun, 19 Feb 2023 19:54:22 +1100 Subject: [PATCH] smaller audio buffer + fill with zeroes before starting --- src/processor/memory/mmio/apu.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/processor/memory/mmio/apu.rs b/src/processor/memory/mmio/apu.rs index fcb9ae3..618a396 100644 --- a/src/processor/memory/mmio/apu.rs +++ b/src/processor/memory/mmio/apu.rs @@ -106,10 +106,12 @@ const CYCLES_PER_FRAME: usize = 70224; impl Apu { pub fn init(&mut self) { let sample_rate = self.config.sample_rate.0; - let rb_len = sample_rate as usize; + let rb_len = sample_rate as usize / 60; let rb = AsyncHeapRb::::new(rb_len); - let (tx, mut rx) = rb.split(); + let (mut tx, mut rx) = rb.split(); + + executor::block_on(tx.push_iter(vec![0.; rb_len - 1].into_iter())).unwrap(); self.send_rb = Some(tx);