include/sound/sound.h
The game's sound: sySoundPlay and the music's volume and tempo ramps (sound.c), the sound test and the heard-sound flags (sound_test.c), over the development kit's sound driver (sdk/sound_driver.h).
#include "types.h"#include "edition.h"#include "sdk/sound_driver.h"#include "sound/stubs.h"#include "system.h"
Included by battle_internal.h, battle_effect_internal.h, field_engine_internal.h, field_internal.h, field_psynergy_internal.h, script_commands_internal.h, menu_internal.h, emote_pop_tilted.c, shop_internal.h, sound.c, sound_test.c, system_internal.h, window_internal.h and script.h.
Structures
| Name | Description | |
|---|---|---|
struct | SOUND_TEST_SOUNDS | The three sounds the sound test's selectors start on. |
Macros
| Name | Description | |
|---|---|---|
#define | SOUND_INFO_BYTE (info, member) | The byte member of the sound driver's state info (struct SoundInfo), read through SoundInfoPointer's bytes without the struct's volatile. |
Enumerations
| Name | Description | |
|---|---|---|
enum | anonymous enum { BGM_UNITY_SCALE, BGM_DEFAULT_RAMP_STEP, TRACKS_ALL, MUSIC_PL … } |
Functions
| Name | Description | |
|---|---|---|
void | m4aSoundMain (void) | Runs the sound driver for one VBlank through SoundMain. |
void | sySoundInit (void) | Starts the sound driver at power-on: no music, the volume and tempo ramps at rest, no player's last sound, and the fixed 31536 Hz output rate. |
void | sySoundPlay (Sint32 id) | Plays a sound number, the game's one way of playing a sound: a fade control, a sound effect, a jingle or music, as The Broken Seal's with this game's ranges (enum SoundControl). |
void | sySoundVSync (void) | Runs the sound driver's VBlank work: the DMA restart count The Broken Seal's sySoundUpdateBGMRamps ran at its end. |
void | sySoundSetBGMTempo (Uint16 tempoScale) | Sets the music's tempo at once; BGM_UNITY_SCALE is the song's own. |
void | sySoundSetBGMPitch (Uint16 pitch) | Applies a pitch offset, in 1/256 semitone, to the music's tracks 0 to 7. |
void | sySoundSetBGMTempoPitchTarget (Uint16 targetScale, Uint16 step) | Sets the target and per-VBlank step of the combined BGM tempo/pitch ramp (BGM_UNITY_SCALE the music's own). |
void | sySoundSetBGMVolume (Sint16 volume) | Sets the music's volume (BGM_UNITY_SCALE full) at once and cancels any volume ramp under way. |
void | sySoundSetBGMVolumeTarget (Uint16 targetVolume, Uint16 step) | Sets the BGM volume target (BGM_UNITY_SCALE full) and its per-VBlank step. |
Uint8 | sySoundGetBGMRestoreDelay (void) | Returns nonzero while a jingle holds the music: from its start until its player falls silent and the music begins to fade back in. |
void | sySoundTestRun (void) | Unused: the sound test, which never returns. |
void | sySoundStopAllMusicPlayers (void) | Stops every sound player while preserving its state for a later resume. |
void | sySoundResumeAllMusicPlayers (void) | Resumes every player, each from where m4aMPlayAllStop stopped it. |
void | sySoundUpdateCommandMask (Uint32 command) | Unused: replaces SoundCommandMask, or flips the bits named with AUDIO_COMMAND_TOGGLE. |
Uint16 | sySoundGetCurrentBGM (void) | Returns the music sySoundPlay last started: MUS_SILENCE before any and after a fade. |
void | sySoundWaitForBGMRestore (void) | Waits until a jingle has ended and the music has begun to come back, giving up after BGM_WAIT_TIMEOUT_TICKS. |
void | sySoundSuspendDirectSound (void) | Stops the sound DMA and its timer; the soft reset calls it first. |
void | sySoundUpdateBGMRamps (void) | Restores BGM after a jingle and steps its volume and combined tempo/pitch ramps once per frame, clamping each ramp when it crosses its target, as The Broken Seal's without the DMA restart count (sySoundVSync here). |
Bool | sySoundFlagTest (Sint32 sound) | Returns whether sound has been heard: its bit in SoundFlags, one for each of the SOUND_FLAG_COUNT sound ids. |
void | sySoundFlagSet (Sint32 sound) | Marks sound as heard. |
void | sySoundFlagClear (Sint32 sound) | Marks sound as not yet heard. |
void | sySoundNoOperation (void) | Unused: does nothing; the stub table exports it. |
Sint32 | sySoundGetReverbCode (Sint32 sound) | Returns the reverb code sySoundPlay gives music sound: SOUND_REVERB_LONG for every one. |
void | sySoundSetFixedSampleFrequency (Uint32 mode) | Sets direct sound to its fixed output rate, keeping mode's rate nibble, clears the PCM buffers and restarts the sound DMAs and timer 0 on them (sound_test.c). |
Sint32 | SoundDriverEnterVBlankUpdate (void) | SoundMain as the tick wait runs it: steps the music players and the CGB channels and starts the IWRAM mixer on this VBlank's PCM, returning 0; it returns 1 with nothing done when the stack is too deep or the driver busy. |
void | SoundDriverVSyncRefresh (void) | The VBlank handler's sound step, as m4aSoundVSync: counts down the PCM buffer's frames and, as it wraps, restarts the two sound DMAs, which then read from the buffer's start again. |
Description
The game's sound: sySoundPlay and the music's volume and tempo ramps
(sound.c), the sound test and the heard-sound flags (sound_test.c), over the
development kit's sound driver (sdk/sound_driver.h).
Macros in detail
SOUND_INFO_BYTE
#define SOUND_INFO_BYTE(info, member)
The byte member of the sound driver's state info (struct SoundInfo), read
through SoundInfoPointer's bytes without the struct's volatile.
Referenced by syVBlankHandler() and syWaitForVBlankInterrupt().
Definition at line 117 of file sound.h.
Enumerations in detail
anonymous enum
enum { BGM_UNITY_SCALE, BGM_DEFAULT_RAMP_STEP, TRACKS_ALL, MUSIC_PLAYER_COUNT, … }
| Enumerator | Value | Description |
|---|---|---|
BGM_UNITY_SCALE | 256 | Full volume, and the song's own tempo and pitch: 1.0 in the ramps' 8.8 fixed point. |
BGM_DEFAULT_RAMP_STEP | 4 | A ramp's step a frame: a full fade in or out takes 64 frames. |
TRACKS_ALL | 0xff | The track mask of every music command here: tracks 0 to 7. |
MUSIC_PLAYER_COUNT | 8 | MusicPlayerLastSound's entries, one a player. |
BGM_RESTORE_DELAY_FRAMES | 10 | Frames after a jingle starts before the music waits for it to end. |
BGM_WAIT_TIMEOUT_TICKS | 300 | sySoundWaitForBGMRestore gives up after this many ticks, about five seconds. |
Definition at line 92 of file sound.h.
Functions in detail
m4aSoundMain
void m4aSoundMain(void)
Runs the sound driver for one VBlank through SoundMain.
Definition at line 17 of file sound.h.
SoundDriverEnterVBlankUpdate
Sint32 SoundDriverEnterVBlankUpdate(void)
SoundMain as the tick wait runs it: steps the music players and the CGB channels and starts the IWRAM mixer on this VBlank's PCM, returning 0; it returns 1 with nothing done when the stack is too deep or the driver busy.
Referenced by syVBlankHandler() and syWaitForVBlankInterrupt().
Definition at line 122 of file sound.h.
SoundDriverVSyncRefresh
void SoundDriverVSyncRefresh(void)
The VBlank handler's sound step, as m4aSoundVSync: counts down the PCM buffer's frames and, as it wraps, restarts the two sound DMAs, which then read from the buffer's start again.
Referenced by syVBlankHandler().
Definition at line 126 of file sound.h.