mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 00:56:38 +11:00
Get rid of references to manual interrupt work
This commit is contained in:
parent
0f5ce17f75
commit
8efbf87c21
2 changed files with 7 additions and 32 deletions
|
@ -45,11 +45,13 @@
|
||||||
//!
|
//!
|
||||||
//! ## Doing the per-frame work
|
//! ## Doing the per-frame work
|
||||||
//!
|
//!
|
||||||
//! Then, you have a choice of whether you want to use interrupts or do the buffer swapping
|
//! Despite being high performance, the mixer still takes a sizable portion of CPU time (6-10%
|
||||||
//! yourself after a vblank interrupt. If you are using 32768Hz as the frequency of your
|
//! depending on number of channels and frequency) to do the per-frame tasks, so should be done
|
||||||
//! files, you _must_ use the interrupt version.
|
//! 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
|
//! ```rust,no_run
|
||||||
//! # #![no_std]
|
//! # #![no_std]
|
||||||
|
@ -61,35 +63,9 @@
|
||||||
//! // Somewhere in your main loop:
|
//! // Somewhere in your main loop:
|
||||||
//! mixer.frame();
|
//! mixer.frame();
|
||||||
//! vblank.wait_for_vblank();
|
//! 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
|
//! ## Loading a sample
|
||||||
//!
|
//!
|
||||||
//! To load a sample, you must have it in `wav` format (both stereo and mono work) at exactly the
|
//! 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,
|
Hz10512,
|
||||||
/// 18157Hz
|
/// 18157Hz
|
||||||
Hz18157,
|
Hz18157,
|
||||||
/// 32768Hz - note that this option requires interrupts for buffer swapping
|
/// 32768Hz
|
||||||
Hz32768,
|
Hz32768,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,6 @@ impl Mixer {
|
||||||
/// loop {
|
/// loop {
|
||||||
/// mixer.frame();
|
/// mixer.frame();
|
||||||
/// vblank.wait_for_vblank();
|
/// vblank.wait_for_vblank();
|
||||||
/// mixer.after_vblank(); // optional, only if not using interrupts
|
|
||||||
/// }
|
/// }
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Add table
Reference in a new issue