Skip to Content
The Alchemy Project

src/sound/sound.c

The game's own sound code over the sound driver, as The Broken Seal's: sySoundPlay, which takes every sound number, the music's volume and tempo ramps, and the music's return after a jingle.

Macros

NameDescription
#defineSEMITONES_PER_OCTAVE 12The semitones of an octave.

Functions

NameDescription
voidsySoundNoOperation (void)Unused: does nothing; the stub table exports it.
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.
Sint32sySoundGetReverbCode (Sint32 sound)Returns the reverb code sySoundPlay gives music sound: SOUND_REVERB_LONG for every one, where The Broken Seal's gives it to three.
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).
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).
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 BGM tempo scale directly; BGM_UNITY_SCALE preserves its native tempo.
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 BGM volume (BGM_UNITY_SCALE full) immediately and cancels any outstanding volume ramp.
voidsySoundSetBGMVolumeTarget (Uint16 targetVolume, Uint16 step)Sets the BGM volume target (BGM_UNITY_SCALE full) and its per-VBlank step.
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.
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.
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.

Description

The game's own sound code over the sound driver, as The Broken Seal's: sySoundPlay, which takes every sound number, the music's volume and tempo ramps, and the music's return after a jingle.

Macros in detail

SEMITONES_PER_OCTAVE

#define SEMITONES_PER_OCTAVE 12

The semitones of an octave.

Referenced by sySoundUpdateBGMRamps().

Definition at line 10 of file sound.c.

Functions in detail

sySoundNoOperation

void sySoundNoOperation(void)

Unused: does nothing; the stub table exports it.

Definition at line 13 of file sound.c.

sySoundInit

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. As The Broken Seal's, but here no music is MUS_SILENCE, sound 0.

References BgmFadeRequested, BgmRestoreDelay, BgmTempoPitch, BgmTempoPitchStep, BgmTempoPitchTarget, BgmVolume, BgmVolumeStep, BgmVolumeTarget, CurrentBgm, MusicPlayerLastSound, Sint32, SoundCommandMask, SoundUnreadByte and sySoundSetFixedSampleFrequency().

Definition at line 20 of file sound.c.

sySoundGetReverbCode

Sint32 sySoundGetReverbCode(Sint32 sound)

Returns the reverb code sySoundPlay gives music sound: SOUND_REVERB_LONG for every one, where The Broken Seal's gives it to three.

References Sint32.

Referenced by sySoundPlay().

Definition at line 45 of file sound.c.

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 Broken Seal's with this game's ranges (enum SoundControl). Every sound is first marked as heard (sySoundFlagSet), and none plays while the tick wait runs the driver's update.

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

Referenced by dbIncreaseItemAndLevelRunLevelEditor(), dbIncreaseItemAndLevelSelectItem(), dbShopTestRunLevelEditor(), dbShopTestSelectItem(), fdActorDropAndWait(), fdScriptPlaySound(), scAirsRockBlowGust(), scAirsRockInsideBlowGust(), scAirsRockInsideCheckPsynergyStone(), scAirsRockInsideFinishPushingPillar(), scAirsRockInsideLandInHall(), scAirsRockInsideOpenTabletRoomDoor(), scAirsRockInsideRideFaceVent(), scAirsRockInsideRideStatuesVent(), scAirsRockInsideRideWhirlwind(), scAirsRockInsideRiseOnLift(), scAirsRockInsideShebaLearnsReveal(), scAirsRockInsideVanishStone(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scAirsRockRideWhirlwind(), scAlhafraFindGoldCoins(), scAlhafraManorBriggsEscapes(), scAlhafraOpenDoorAndEnter(), scAncientLemuriaHeadForTheDock(), scAncientLemuriaRockTheStatue(), scAnemosInnerSanctumDullahanLightRises(), scAnemosInnerSanctumDullahanMoveBlock(), scAnemosInnerSanctumDullahanOpenTheWay(), scApojiiIslandsDouseAquaStone(), scAquaRockArriveFromInside(), scAquaRockArriveFromPassage(), scAquaRockDouseSummitWaterStone(), scAquaRockEnterSparklingPassage(), scAquaRockInsidePiersLearnsParch(), scAquaRockMoaiStepAside(), scAquaRockSinkInside(), scAttekaInletOpenDoorAndEnter(), scCavernsFinishMovingAngaraBlock(), scCavernsJumpAcross(), scCavernsOpenAngaraDoor(), scCavernsWalkIntoPassage(), scChampaCliffCavesFightAvimander(), scChampaCliffCavesLightForge(), scChampaCliffCavesObabaAsksForBriggs(), scChampaCliffCavesObabaForgesTrident(), scChampaCliffCavesOpenDoorAndEnter(), scChampaCliffCavesRaiseColumn(), scChampaCliffCavesStartFlash(), scClearEnterPassword() and 108 more.

Definition at line 55 of file sound.c.

sySoundUpdateBGMRamps

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

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

Definition at line 149 of file sound.c.

sySoundVSync

void sySoundVSync(void)

Runs the sound driver's VBlank work: the DMA restart count The Broken Seal's sySoundUpdateBGMRamps ran at its end. Reached through the stub call slot that function had.

Definition at line 207 of file sound.c.

sySoundSetBGMTempo

void sySoundSetBGMTempo(Uint16 tempoScale)

Sets the BGM tempo scale directly; BGM_UNITY_SCALE preserves its native tempo.

References MPlayInfoBGM.

Definition at line 214 of file sound.c.

sySoundSetBGMPitch

void sySoundSetBGMPitch(Uint16 pitch)

Applies a pitch offset, in 1/256 semitone, to the music's tracks 0 to 7.

References MPlayInfoBGM.

Definition at line 220 of file sound.c.

sySoundSetBGMTempoPitchTarget

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

References BgmTempoPitchStep and BgmTempoPitchTarget.

Definition at line 227 of file sound.c.

sySoundSetBGMVolume

void sySoundSetBGMVolume(Sint16 volume)

Sets BGM volume (BGM_UNITY_SCALE full) immediately and cancels any outstanding volume ramp.

References BgmVolume, BgmVolumeTarget and MPlayInfoBGM.

Definition at line 235 of file sound.c.

sySoundSetBGMVolumeTarget

void sySoundSetBGMVolumeTarget(Uint16 targetVolume, Uint16 step)

Sets the BGM volume target (BGM_UNITY_SCALE full) and its per-VBlank step.

References BgmVolumeStep and BgmVolumeTarget.

Definition at line 243 of file sound.c.

sySoundStopAllMusicPlayers

void sySoundStopAllMusicPlayers(void)

Stops every sound player while preserving its state for a later resume.

Definition at line 250 of file sound.c.

sySoundResumeAllMusicPlayers

void sySoundResumeAllMusicPlayers(void)

Resumes every player, each from where m4aMPlayAllStop stopped it.

Definition at line 256 of file sound.c.

sySoundGetBGMRestoreDelay

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.

References BgmRestoreDelay.

Definition at line 263 of file sound.c.

sySoundWaitForBGMRestore

void sySoundWaitForBGMRestore(void)

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

References BgmRestoreDelay, Sint32 and sySynch().

Referenced by scAquaRockInsideUseAquariusStone() and scInit().

Definition at line 270 of file sound.c.

sySoundSuspendDirectSound

void sySoundSuspendDirectSound(void)

Stops the sound DMA and its timer; the soft reset calls it first.

Definition at line 284 of file sound.c.