Alchemy
Loading...
Searching...
No Matches

sound.c File Reference

Go to the source code of this file.

Enumerations

enum  {
  MUSIC_UNITY_SCALE = 0x100 , MUSIC_DEFAULT_RAMP_STEP = 4 , MUSIC_ALL_TRACKS = 0xff , MUSIC_PLAYER_COUNT = 8 ,
  MUSIC_RESTORE_DELAY_FRAMES = 10 , MUSIC_WAIT_TIMEOUT_FRAMES = 300
}

Functions

void AudioCommand_Play (s32 id)
 Dispatches a packed cue: fade controls, allocated sound effects, fanfares, or background music with an optional silent start.
void MusicPlayer_StepVolumeAndPitchTowardTargets (void)
 Restores BGM after a fanfare and steps its volume and combined tempo/pitch ramps once per VBlank, clamping each ramp when it crosses its target.
void AudioTest_RunParameterController (void)
 Runs the audio test's three cue selectors and five mixer presets forever.
void Audio_InitializeRuntimeDefaults (void)
 Starts the sound driver, resets the BGM ramps (gMusicVolume and its kin) and clears all player cue records.
void MusicCommand_SetPitchAndUpdateFrequency (u16 tempoScale)
 Sets the BGM tempo scale directly; 0x100 preserves its native tempo.
void MusicCommand_SetPitch (u16 pitch)
 Applies a pitch offset to every active BGM track.
void Audio_SetWorkPairB (u16 targetScale, u16 step)
 Sets the target and per-frame step of the combined BGM tempo/pitch ramp.
void MusicCommand_SetVolume (s16 volume)
 Sets BGM volume immediately and cancels any outstanding volume ramp.
void Audio_SetMusicVolumeTargetAndStep (u16 targetVolume, u16 step)
 Sets the BGM volume target and its per-frame adjustment.
s32 AudioCommand_GetStateByte (void)
 Returns the remaining delay before BGM can be restored after a fanfare.
void AudioCommand_StopAllPlayers (void)
 Stops every sound player while preserving its state for a later resume.
void AudioCommand_ResumeAllPlayers (void)
void AudioCommand_UpdateToggleMask (u32 command)
 Replaces the audio command mask, or toggles its requested bits when flagged.
s32 AudioCommand_GetSecondaryStateByte (void)
 Returns the last BGM cue or fade state selected by AudioCommand_Play.
void AudioCommand_WaitForCompletion (void)
 Waits a frame at a time for fanfare restoration, giving up after 300 frames.
UNUSED s32 AudioCommand_GetWidth (s32 command)
 Returns the mixer preset chosen by the cue dispatcher.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MUSIC_UNITY_SCALE 
MUSIC_DEFAULT_RAMP_STEP 
MUSIC_ALL_TRACKS 
MUSIC_PLAYER_COUNT 
MUSIC_RESTORE_DELAY_FRAMES 
MUSIC_WAIT_TIMEOUT_FRAMES 

Definition at line 20 of file sound.c.

Function Documentation

◆ AudioCommand_Play()

void AudioCommand_Play ( s32 id)

Dispatches a packed cue: fade controls, allocated sound effects, fanfares, or background music with an optional silent start.

Reached through the sound far-call table as AudioCommand_PlayFar, which the whole game calls to play music and sound effects; it updates the music layer's cue records.

Definition at line 33 of file sound.c.

Referenced by AudioCommand_Play(), and AudioTest_RunParameterController().

◆ MusicPlayer_StepVolumeAndPitchTowardTargets()

void MusicPlayer_StepVolumeAndPitchTowardTargets ( void )

Restores BGM after a fanfare and steps its volume and combined tempo/pitch ramps once per VBlank, clamping each ramp when it crosses its target.

Called by System_VBlankHandler through the sound far-call table.

Definition at line 92 of file sound.c.

Referenced by MusicPlayer_StepVolumeAndPitchTowardTargets().

◆ AudioTest_RunParameterController()

void AudioTest_RunParameterController ( void )

Runs the audio test's three cue selectors and five mixer presets forever.

Buttons play, fade or adjust the selected cue while frames keep advancing. Reached only through the sound far-call table's veneer; nothing in ☀️ names it.

Definition at line 138 of file sound.c.

Referenced by AudioTest_RunParameterController().

◆ Audio_InitializeRuntimeDefaults()

void Audio_InitializeRuntimeDefaults ( void )

Starts the sound driver, resets the BGM ramps (gMusicVolume and its kin) and clears all player cue records.

Called by System_Initialize through the sound far-call table.

Definition at line 201 of file sound.c.

Referenced by Audio_InitializeRuntimeDefaults().

◆ MusicCommand_SetPitchAndUpdateFrequency()

void MusicCommand_SetPitchAndUpdateFrequency ( u16 tempoScale)

Sets the BGM tempo scale directly; 0x100 preserves its native tempo.

Called through the far-call table, by the Lemurian ship's sailing among others.

Definition at line 228 of file sound.c.

Referenced by MusicCommand_SetPitchAndUpdateFrequency(), and SetSail().

◆ MusicCommand_SetPitch()

void MusicCommand_SetPitch ( u16 pitch)

Applies a pitch offset to every active BGM track.

Reached only through the sound far-call table's veneer.

Definition at line 234 of file sound.c.

Referenced by MusicCommand_SetPitch().

◆ Audio_SetWorkPairB()

void Audio_SetWorkPairB ( u16 targetScale,
u16 step )

Sets the target and per-frame step of the combined BGM tempo/pitch ramp.

Reached only through the sound far-call table's veneer.

Definition at line 240 of file sound.c.

Referenced by Audio_SetWorkPairB().

◆ MusicCommand_SetVolume()

void MusicCommand_SetVolume ( s16 volume)

Sets BGM volume immediately and cancels any outstanding volume ramp.

Reached only through the sound far-call table's veneer.

Definition at line 247 of file sound.c.

Referenced by MusicCommand_SetVolume().

◆ Audio_SetMusicVolumeTargetAndStep()

void Audio_SetMusicVolumeTargetAndStep ( u16 targetVolume,
u16 step )

Sets the BGM volume target and its per-frame adjustment.

Reached only through the sound far-call table's veneer.

Definition at line 255 of file sound.c.

Referenced by Audio_SetMusicVolumeTargetAndStep().

◆ AudioCommand_GetStateByte()

◆ AudioCommand_StopAllPlayers()

void AudioCommand_StopAllPlayers ( void )

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

Definition at line 264 of file sound.c.

Referenced by AudioCommand_StopAllPlayers().

◆ AudioCommand_ResumeAllPlayers()

void AudioCommand_ResumeAllPlayers ( void )

Definition at line 266 of file sound.c.

Referenced by AudioCommand_ResumeAllPlayers().

◆ AudioCommand_UpdateToggleMask()

void AudioCommand_UpdateToggleMask ( u32 command)

Replaces the audio command mask, or toggles its requested bits when flagged.

Reached only through the sound far-call table's veneer.

Definition at line 270 of file sound.c.

Referenced by AudioCommand_UpdateToggleMask().

◆ AudioCommand_GetSecondaryStateByte()

s32 AudioCommand_GetSecondaryStateByte ( void )

Returns the last BGM cue or fade state selected by AudioCommand_Play.

Definition at line 281 of file sound.c.

Referenced by AudioCommand_GetSecondaryStateByte().

◆ AudioCommand_WaitForCompletion()

void AudioCommand_WaitForCompletion ( void )

Waits a frame at a time for fanfare restoration, giving up after 300 frames.

Called by scenes before they go on after a fanfare (Sol Sanctum's quest acceptance among them).

Definition at line 286 of file sound.c.

Referenced by AudioCommand_WaitForCompletion(), Event_ReconsiderQuest(), and Sanctum_RequestQuestAcceptance().

◆ AudioCommand_GetWidth()

UNUSED s32 AudioCommand_GetWidth ( s32 command)

Returns the mixer preset chosen by the cue dispatcher.

Nothing in ☀️ calls it.

Definition at line 299 of file sound.c.

Referenced by AudioCommand_GetWidth().