Skip to Content
The Alchemy Project

src/sound/sound.c

The game's own sound code over the sound driver: sySoundPlay, which takes every sound number, the music's volume and tempo ramps, the music's return after a jingle, and a sound test nothing in the game names.

Macros

NameDescription
#defineSEMITONES_PER_OCTAVE 12The semitones of an octave.

Enumerations

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

Functions

NameDescription
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 README's "What a sound number means" describes.
voidsySoundUpdateBGMRamps (void)Runs once a VBlank: brings the music back after a jingle and steps its volume and its tempo and pitch toward their targets, stopping on each.
voidsySoundTestRun (void)Unused: a sound test that never returns.
voidsySoundInit (void)Starts the sound driver at power-on, with the music at full volume and its own tempo, and no music chosen yet.
voidsySoundSetBGMTempo (Uint16 tempoScale)Plays the music at a tempo scale at once, BGM_UNITY_SCALE its own; its pitch stays.
voidsySoundSetBGMPitch (Uint16 pitch)Unused: transposes the music's tracks 0 to 7 by pitch, in 1/256 semitone.
voidsySoundSetBGMTempoPitchTarget (Uint16 targetScale, Uint16 step)Unused: ramps the music's tempo and pitch together toward targetScale (BGM_UNITY_SCALE its own) by step a frame.
voidsySoundSetBGMVolume (Sint16 volume)Unused: sets the music's volume at once (BGM_UNITY_SCALE full), ending any fade toward another.
voidsySoundSetBGMVolumeTarget (Uint16 targetVolume, Uint16 step)Unused: fades the music toward targetVolume (BGM_UNITY_SCALE full) by step a frame.
Sint32sySoundGetBGMRestoreDelay (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.
voidsySoundStopAllMusicPlayers (void)Unused: stops every music player where it is, for sySoundResumeAllMusicPlayers to go on from.
voidsySoundResumeAllMusicPlayers (void)Unused: resumes every music player from where sySoundStopAllMusicPlayers stopped it.
voidsySoundUpdateCommandMask (Uint32 command)Unused: sets SoundCommandMaskWork, or with SOUND_COMMAND_MASK_TOGGLE flips the bits given; nothing reads the mask.
Sint32sySoundGetCurrentBGM (void)Returns the music sySoundPlay last chose: BGM_NONE before any, MUS_SILENCE after a fade.
voidsySoundWaitForBGMRestore (void)Waits until the music has begun to come back after a jingle, giving up after BGM_WAIT_TIMEOUT_TICKS.
Sint32sySoundGetReverbCode (Sint32 command)Unused: returns the reverb code sySoundPlay gives music command: SOUND_REVERB_LONG for MUS_THE_BROKEN_SEAL_ENDING, MUS_MAIN_THEME_TITLE and MUS_TO_BE_CONTINUED, SOUND_REVERB_NORMAL for the rest.

Description

The game's own sound code over the sound driver: sySoundPlay, which takes every sound number, the music's volume and tempo ramps, the music's return after a jingle, and a sound test nothing in the game names.

Macros in detail

SEMITONES_PER_OCTAVE

#define SEMITONES_PER_OCTAVE 12

The semitones of an octave.

Referenced by sySoundUpdateBGMRamps().

Definition at line 33 of file sound.c.

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.
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.
BGM_NONE255CurrentBgm before any music: an id no music has, so the first music always plays.

Definition at line 12 of file sound.c.

Functions in detail

sySoundPlay

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 README's "What a sound number means" describes.

References BgmFadeRequested, BgmRestoreDelay, BgmVolume, BgmVolumeStep, BgmVolumeTarget, CurrentBgm, MPlayInfoActionSE, MPlayInfoBGM, MusicPlayerLastSound, Sint32 and sySoundLoadReverbCode().

Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectAbility(), dbIncreaseItemAndLevelSelectItem(), dbMenuTestSelectItem(), fdScriptPlaySound(), scAlpineCrossingLiftBoulder(), scAltinBeastHop(), scAltinBeastHopAway(), scAltinEnterDoor(), scAltinPeakAdvanceCart(), scAltinPeakBeastFreezesSecondPuddle(), scAltinPeakCelebrateHydrosVictory(), scAltinPeakDrainFirstWater(), scAltinPeakDrainSecondWater(), scAltinPeakDrainThirdWater(), scAltinPeakFirstBeastHopsAway(), scAltinPeakFlickerWaterAway(), scAltinPeakFlipPoolRoomSwitch(), scAltinPeakFlipSecondWaterBeastRoomSwitch(), scAltinPeakFlipSpritzRoomSwitch(), scAltinPeakFlipThirdWaterBeastRoomSwitch(), scAltinPeakForceLogOver(), scAltinPeakPlayHydrosRumble(), scAltinPeakPlayLandingShake(), scAltinPeakPushSpritzRoomPillar(), scAltinPeakReadFallingRockSign(), scAltinPeakRideCart(), scAltinPeakRollCart(), scAltinPeakRunBoulderChase(), scAltinPeakShowFirstBeastRoute(), scAltinPeakSpawnDebris(), scAltinPeakStartCartCountdown(), scAltinPeakStartHydrosBattle(), scAltinPeakStopCartAndJumpOff(), scAltinPeakTurnCartLeft(), scAltinPeakTurnCartRight(), scAltinPeakUpdateBeastHops(), scAltinScareOffBeast(), scAltinWalkIntoMine(), scAltmillerCaveHopOverPuddle(), scAltmillerCaveMeetInvisibleBabi(), scAltmillerCaveRestoreBabiAndInviteParty(), scAltmillerCaveSpinLights(), scAltmillerCaveTurnRock(), scAltmillerCaveUpdateWallFragment(), scBabiLighthouseCloseTruthDoor(), scBabiLighthouseFallToExit(), scBabiLighthouseInspectTruthDoorSwitch(), scBabiLighthouseLandWithParticles(), scBabiLighthouseOpenTruthDoor() and 488 more.

Definition at line 38 of file sound.c.

sySoundUpdateBGMRamps

void sySoundUpdateBGMRamps(void)

Runs once a VBlank: brings the music back after a jingle and steps its volume and its tempo and pitch toward their targets, stopping on each.

References BgmRestoreDelay, BgmTempoPitch, BgmTempoPitchStep, BgmTempoPitchTarget, BgmVolume, BgmVolumeStep, BgmVolumeTarget, MPlayInfoBGM, MPlayInfoJingle and Sint32.

Definition at line 124 of file sound.c.

sySoundTestRun

void sySoundTestRun(void)

Unused: a sound test that never returns. Up and Down choose a row (music, jingles, sound effects), Left and Right step its number by 1 and L and R by 10, A plays it, B silences the music, Start fades it out, and Select fades the action sounds and moves to the next reverb code. Only a bare stub call stub, which no code names, leads here.

References BuildStampWork, PerRepeat, Sint32, SoundMixerClipped, sySoundLoadReverbCode(), sySoundPlay() and sySynch().

Definition at line 200 of file sound.c.

sySoundInit

void sySoundInit(void)

Starts the sound driver at power-on, with the music at full volume and its own tempo, and no music chosen yet.

References BgmFadeRequested, BgmRestoreDelay, BgmTempoPitch, BgmTempoPitchStep, BgmTempoPitchTarget, BgmVolume, BgmVolumeStep, BgmVolumeTarget, CurrentBgm, MusicPlayerLastSound, Sint32, SoundCommandMaskWork and SoundUnreadByte.

Definition at line 264 of file sound.c.

sySoundSetBGMTempo

void sySoundSetBGMTempo(Uint16 tempoScale)

Plays the music at a tempo scale at once, BGM_UNITY_SCALE its own; its pitch stays. The Lemurian ship slows it to fifteen sixteenths.

References MPlayInfoBGM.

Referenced by scLemurianShipSetSail().

Definition at line 286 of file sound.c.

sySoundSetBGMPitch

void sySoundSetBGMPitch(Uint16 pitch)

Unused: transposes the music's tracks 0 to 7 by pitch, in 1/256 semitone. Only a bare stub, which no code names, leads here.

References MPlayInfoBGM.

Definition at line 293 of file sound.c.

sySoundSetBGMTempoPitchTarget

void sySoundSetBGMTempoPitchTarget(Uint16 targetScale, Uint16 step)

Unused: ramps the music's tempo and pitch together toward targetScale (BGM_UNITY_SCALE its own) by step a frame. Only a bare stub, which no code names, leads here.

References BgmTempoPitchStep and BgmTempoPitchTarget.

Definition at line 301 of file sound.c.

sySoundSetBGMVolume

void sySoundSetBGMVolume(Sint16 volume)

Unused: sets the music's volume at once (BGM_UNITY_SCALE full), ending any fade toward another. Only a bare stub, which no code names, leads here.

References BgmVolume, BgmVolumeTarget and MPlayInfoBGM.

Definition at line 309 of file sound.c.

sySoundSetBGMVolumeTarget

void sySoundSetBGMVolumeTarget(Uint16 targetVolume, Uint16 step)

Unused: fades the music toward targetVolume (BGM_UNITY_SCALE full) by step a frame. Only a bare stub, which no code names, leads here.

References BgmVolumeStep and BgmVolumeTarget.

Definition at line 318 of file sound.c.

sySoundGetBGMRestoreDelay

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

References BgmRestoreDelay and Sint32.

Referenced by scColossoShowMatchResult() and scColossoShowOpeningLettering().

Definition at line 326 of file sound.c.

sySoundStopAllMusicPlayers

void sySoundStopAllMusicPlayers(void)

Unused: stops every music player where it is, for sySoundResumeAllMusicPlayers to go on from. Only a bare stub, which no code names, leads here.

Definition at line 334 of file sound.c.

sySoundResumeAllMusicPlayers

void sySoundResumeAllMusicPlayers(void)

Unused: resumes every music player from where sySoundStopAllMusicPlayers stopped it. Only a bare stub, which no code names, leads here.

Definition at line 341 of file sound.c.

sySoundUpdateCommandMask

void sySoundUpdateCommandMask(Uint32 command)

Unused: sets SoundCommandMaskWork, or with SOUND_COMMAND_MASK_TOGGLE flips the bits given; nothing reads the mask. Only a bare stub, which no code names, leads here.

References SoundCommandMaskWork.

Definition at line 349 of file sound.c.

sySoundGetCurrentBGM

Sint32 sySoundGetCurrentBGM(void)

Returns the music sySoundPlay last chose: BGM_NONE before any, MUS_SILENCE after a fade.

References CurrentBgm and Sint32.

Definition at line 362 of file sound.c.

sySoundWaitForBGMRestore

void sySoundWaitForBGMRestore(void)

Waits until the music has begun to come back after a jingle, giving up after BGM_WAIT_TIMEOUT_TICKS.

References BgmRestoreDelay, Sint32 and sySynch().

Referenced by scSanctumAskQuestAgain() and scSanctumAskToAcceptQuest().

Definition at line 369 of file sound.c.

sySoundGetReverbCode

Sint32 sySoundGetReverbCode(Sint32 command)

Unused: returns the reverb code sySoundPlay gives music command: SOUND_REVERB_LONG for MUS_THE_BROKEN_SEAL_ENDING, MUS_MAIN_THEME_TITLE and MUS_TO_BE_CONTINUED, SOUND_REVERB_NORMAL for the rest.

References Sint32.

Definition at line 385 of file sound.c.