From e150005eda36c1cc12dfa6ccd20aebdcb7ad9841 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Fri, 17 Feb 2023 11:07:03 +1100 Subject: [PATCH] correct for machine cycles --- src/processor/memory/mmio/apu.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/processor/memory/mmio/apu.rs b/src/processor/memory/mmio/apu.rs index 3085f95..daaaba7 100644 --- a/src/processor/memory/mmio/apu.rs +++ b/src/processor/memory/mmio/apu.rs @@ -76,7 +76,7 @@ impl Default for Apu { .config(); let converter = Samplerate::new( - ConverterType::ZeroOrderHold, + ConverterType::SincFastest, CLOCK_SPEED as u32, config.sample_rate.0, 2, @@ -100,7 +100,7 @@ impl Default for Apu { } } -const CYCLES_PER_FRAME: usize = 70224; +const CYCLES_PER_FRAME: usize = 70224 / 4; impl Apu { pub fn init(&mut self) { @@ -118,8 +118,9 @@ impl Apu { &self.config, move |data: &mut [f32], _info: &cpal::OutputCallbackInfo| { for v in data { - if let Some(a) = executor::block_on(rx.pop()) { - *v = a; + match executor::block_on(rx.pop()) { + Some(a) => *v = a, + None => panic!("Audio queue disconnected!"), } } },