From 8efbf87c21ceeb3deeb8096e21767a372479d058 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Fri, 9 Dec 2022 23:09:16 +0000 Subject: [PATCH] Get rid of references to manual interrupt work --- agb/src/sound/mixer/mod.rs | 38 ++++++--------------------------- agb/src/sound/mixer/sw_mixer.rs | 1 - 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/agb/src/sound/mixer/mod.rs b/agb/src/sound/mixer/mod.rs index e0f0ca3b..3f43d7b5 100644 --- a/agb/src/sound/mixer/mod.rs +++ b/agb/src/sound/mixer/mod.rs @@ -45,11 +45,13 @@ //! //! ## Doing the per-frame work //! -//! Then, you have a choice of whether you want to use interrupts or do the buffer swapping -//! yourself after a vblank interrupt. If you are using 32768Hz as the frequency of your -//! files, you _must_ use the interrupt version. +//! Despite being high performance, the mixer still takes a sizable portion of CPU time (6-10% +//! depending on number of channels and frequency) to do the per-frame tasks, so should be done +//! towards the end of the frame time (just before waiting for vblank) in order to give as much +//! time during vblank as possible for rendering related tasks. //! -//! Without interrupts: +//! In order to avoid skipping audio, call the [`Mixer::frame()`] function at least once per frame +//! as shown below: //! //! ```rust,no_run //! # #![no_std] @@ -61,35 +63,9 @@ //! // Somewhere in your main loop: //! mixer.frame(); //! vblank.wait_for_vblank(); -//! mixer.after_vblank(); //! # } //! ``` //! -//! Or with interrupts: -//! -//! ```rust,no_run -//! # #![no_std] -//! # #![no_main] -//! use agb::sound::mixer::Frequency; -//! # fn foo(gba: &mut agb::Gba) { -//! let mut mixer = gba.mixer.mixer(agb::sound::mixer::Frequency::Hz32768); -//! let vblank = agb::interrupt::VBlank::get(); -//! // outside your main loop, close to initialisation -//! // you must assign this to a variable (not to _ or ignored) or rust will immediately drop it -//! // and prevent the interrupt handler from firing. -//! let _mixer_interrupt = mixer.setup_interrupt_handler(); -//! -//! // inside your main loop -//! mixer.frame(); -//! vblank.wait_for_vblank(); -//! # } -//! ``` -//! -//! Despite being high performance, the mixer still takes a sizable portion of CPU time (6-10% -//! depending on number of channels and frequency) to do the per-frame tasks, so should be done -//! towards the end of the frame time (just before waiting for vblank) in order to give as much -//! time during vblank as possible for rendering related tasks. -//! //! ## Loading a sample //! //! To load a sample, you must have it in `wav` format (both stereo and mono work) at exactly the @@ -159,7 +135,7 @@ pub enum Frequency { Hz10512, /// 18157Hz Hz18157, - /// 32768Hz - note that this option requires interrupts for buffer swapping + /// 32768Hz Hz32768, } diff --git a/agb/src/sound/mixer/sw_mixer.rs b/agb/src/sound/mixer/sw_mixer.rs index 0316f3bb..cf161a30 100644 --- a/agb/src/sound/mixer/sw_mixer.rs +++ b/agb/src/sound/mixer/sw_mixer.rs @@ -187,7 +187,6 @@ impl Mixer { /// loop { /// mixer.frame(); /// vblank.wait_for_vblank(); - /// mixer.after_vblank(); // optional, only if not using interrupts /// } /// # } /// ```