Skip to Content
The Alchemy Project

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).

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

NameDescription
structSOUND_TEST_SOUNDSThe three sounds the sound test's selectors start on.

Macros

NameDescription
#defineSOUND_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

NameDescription
enumanonymous enum { BGM_UNITY_SCALE, BGM_DEFAULT_RAMP_STEP, TRACKS_ALL, MUSIC_PL … }

Functions

NameDescription
voidm4aSoundMain (void)Runs the sound driver for one VBlank through SoundMain.
voidsySoundInit (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.
voidsySoundPlay (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).
voidsySoundVSync (void)Runs the sound driver's VBlank work: the DMA restart count The Broken Seal's sySoundUpdateBGMRamps ran at its end.
voidsySoundSetBGMTempo (Uint16 tempoScale)Sets the music's tempo at once; BGM_UNITY_SCALE is the song's own.
voidsySoundSetBGMPitch (Uint16 pitch)Applies a pitch offset, in 1/256 semitone, to the music's tracks 0 to 7.
voidsySoundSetBGMTempoPitchTarget (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).
voidsySoundSetBGMVolume (Sint16 volume)Sets the music's volume (BGM_UNITY_SCALE full) at once and cancels any volume ramp under way.
voidsySoundSetBGMVolumeTarget (Uint16 targetVolume, Uint16 step)Sets the BGM volume target (BGM_UNITY_SCALE full) and its per-VBlank step.
Uint8sySoundGetBGMRestoreDelay (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.
voidsySoundTestRun (void)Unused: the sound test, which never returns.
voidsySoundStopAllMusicPlayers (void)Stops every sound player while preserving its state for a later resume.
voidsySoundResumeAllMusicPlayers (void)Resumes every player, each from where m4aMPlayAllStop stopped it.
voidsySoundUpdateCommandMask (Uint32 command)Unused: replaces SoundCommandMask, or flips the bits named with AUDIO_COMMAND_TOGGLE.
Uint16sySoundGetCurrentBGM (void)Returns the music sySoundPlay last started: MUS_SILENCE before any and after a fade.
voidsySoundWaitForBGMRestore (void)Waits until a jingle has ended and the music has begun to come back, giving up after BGM_WAIT_TIMEOUT_TICKS.
voidsySoundSuspendDirectSound (void)Stops the sound DMA and its timer; the soft reset calls it first.
voidsySoundUpdateBGMRamps (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).
BoolsySoundFlagTest (Sint32 sound)Returns whether sound has been heard: its bit in SoundFlags, one for each of the SOUND_FLAG_COUNT sound ids.
voidsySoundFlagSet (Sint32 sound)Marks sound as heard.
voidsySoundFlagClear (Sint32 sound)Marks sound as not yet heard.
voidsySoundNoOperation (void)Unused: does nothing; the stub table exports it.
Sint32sySoundGetReverbCode (Sint32 sound)Returns the reverb code sySoundPlay gives music sound: SOUND_REVERB_LONG for every one.
voidsySoundSetFixedSampleFrequency (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).
Sint32SoundDriverEnterVBlankUpdate (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.
voidSoundDriverVSyncRefresh (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, … }

EnumeratorValueDescription
BGM_UNITY_SCALE256Full volume, and the song's own tempo and pitch: 1.0 in the ramps' 8.8 fixed point.
BGM_DEFAULT_RAMP_STEP4A ramp's step a frame: a full fade in or out takes 64 frames.
TRACKS_ALL0xffThe track mask of every music command here: tracks 0 to 7.
MUSIC_PLAYER_COUNT8MusicPlayerLastSound's entries, one a player.
BGM_RESTORE_DELAY_FRAMES10Frames after a jingle starts before the music waits for it to end.
BGM_WAIT_TIMEOUT_TICKS300sySoundWaitForBGMRestore 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.