Expand description
The four sound channels and the mixer.
Each channel has a configuration type: Pulse for channels 1 and 2,
Wave for channel 3, Noise for channel 4. Building one is a chain of
const methods, and play writes it out and starts the channel.
const JUMP: Pulse = Pulse::new(12).note(Note::C, 5).length(8);
JUMP.play_ch2();A sound played from one place belongs in a constant. A set of them played from the same place belongs in a table.
See https://gbdev.io/pandocs/Audio.html.
§Power
The boot ROM leaves the APU on at full volume. A program that only wants
sound has nothing to set up. It does leave channels 3 and 4 reaching the
left output alone, which set_panning settles.
power_off draws less current and is worth having on a pause screen;
power_on comes back from it.
§Writing to DIV
Envelopes, length timers and the channel 1 sweep are all counted off DIV,
so timer::reset_divider steps them early.
Resetting it while sound is playing is audible.
Structs§
- Noise
- Channel 4’s settings.
- Pulse
- A pulse channel’s settings.
- Wave
- Channel 3’s settings, which play whatever
load_wavelast put in wave RAM.
Enums§
Functions§
- load_
wave - Load the 32 four-bit samples channel 3 plays, high nibble of each byte first.
- output
cgb - What a channel is putting out, from 0 to 15.
- playing
- Whether a channel is still running.
- power_
off - Power the APU off.
- power_
on - Power the APU on.
- set_
master - Set the master volume.
- set_
panning - Set which channels reach which output.
- silence
- Take a channel down to nothing without stopping it.
- stop
- Stop a channel by turning its DAC off.