The sound tables (CGB codes, frequency steps, frame lengths) and the sound routines. More...
Go to the source code of this file.
Functions | |
| void | Audio_ResumeAllPlayers (void) |
| Resumes every player. Nothing in ☀️ calls it. | |
| void | Audio_ResumePlayer (struct SoundPlayer *player) |
| Clears the player's paused flag while holding the player lock. | |
| void | Audio_StopAllPlayers (void) |
| Stops every player. Nothing in ☀️ calls it. | |
| u32 | Audio_UmulHigh32 (u32 left, u32 right) |
| void | AudioEngine_Initialize (struct SoundWork *work) |
| Resets the sound hardware, clears the whole sound work block and installs the default PCM driver: stores work in SOUND_WORK, points the FIFO DMAs at its two buffers, fills in the driver callbacks and command table, sets the default rate and finally sets the work's lock. | |
| void | AudioEngine_ResumeDirectSound (void) |
| Restarts both FIFO transfers and releases the suspended-work lock. | |
| void | AudioEngine_RunMixerTick (void) |
| void | AudioEngine_SetMode (u32 mode) |
| Applies the reverb, channel-count, volume, bias and sample-rate fields of mode to the sound work, under its lock. | |
| void | AudioEngine_SetPcmRate (u32 mode) |
| Sets the PCM frame length (mode bits 16 to 19 pick a gSound_FrameLengths entry) and the rates derived from it, and Timer 0's reload, starting playback at scanline 159. | |
| void | AudioEngine_SuspendDirectSound (void) |
| Stops both FIFO transfers and clears their sample buffers, raising the work's lock until AudioEngine_ResumeDirectSound. | |
| s32 | Cgb_KeyToFrequency (u8 kind, u8 key, u8 fine) |
| Converts a key and fractional pitch to a CGB tone or noise-register value. | |
| void | Cgb_UpdateChannels (void) |
| Steps CGB note envelopes and writes changed pitch, volume and trigger registers, once a frame. | |
| void | CgbChannel_Mute (u8 channel) |
| Disables one CGB channel using its envelope or wave-control register. | |
| void | MusicPlayer_BeginFadeOut (struct SoundPlayer *player, u16 speed) |
| Begins a fade that stops and clears tracks when its volume reaches zero. | |
| void | MusicPlayer_Initialize (struct SoundPlayer *player, struct SoundTrack *tracks, u8 count) |
| Deactivates up to sixteen tracks and links the player into the mixer tick chain. | |
| void | MusicPlayer_StepFade (struct SoundPlayer *player) |
| Advances a due fade step, updating active track volumes, or at the end of a fade out stops (or pauses) the player. | |
| void | MusicPlayer_Stop (struct SoundPlayer *player) |
| Pauses this player and stops all of its tracks, under the player's lock. | |
| void | MusicPlayer_Tick (struct SoundPlayer *player) |
| void | MusicTrack_CalcOutput (struct SoundPlayer *player, struct SoundTrack *track) |
| Recalculates dirty stereo volumes and pitch from track settings and modulation. | |
| void | MusicTrack_HandleNote (u32 command, struct SoundPlayer *player, struct SoundTrack *track) |
| void | MusicTrack_OperateWorkByte (struct SoundPlayer *player, struct SoundTrack *track) |
| Executes a work-byte operation and consumes a branch address for comparisons. | |
| void | MusicTrack_ReleaseKey (struct SoundPlayer *player, struct SoundTrack *track) |
| void | MusicTrack_SetLfoSpeedFromCommand (struct SoundPlayer *player, struct SoundTrack *track) |
| void | MusicTrack_SetModulationFromCommand (struct SoundPlayer *player, struct SoundTrack *track) |
| void | MusicTrack_Stop (struct SoundPlayer *player, struct SoundTrack *track) |
| void | Sound_Mixer (void) |
| void | Audio_Initialize (void) |
| Copies the RAM mixer to IWRAM, initializes the PCM and CGB paths and configures every player from gSound_PlayerSlots. | |
| void | Audio_PlaySound (u16 id) |
| Starts the song on the player selected by its song-table entry. | |
| void | Sound_TickDmaRestartTimer (void) |
Variables | |
| const u8 | gSound_Cgb3LevelCodes [] |
| CGB channel 3 waveform volumes. | |
| const s16 | gSound_CgbFrequencySteps [] |
| Frequencies by note for CGB channels. | |
| const u8 | gSound_CgbPitchCodes [] |
| CGB channel pitches. | |
| const u16 | gSound_FrameLengths [] |
| Samples per frame for each playback frequency setting. | |
| const u8 | gSound_NoisePitchCodes [] |
| Noise channel pitches. | |
| u32 | gSound_PcmFrequencySteps [] |
| Frequencies by note at octave zero, in 32-bit fixed point. | |
| u8 | gSound_PcmPitchCodes [] |
| PCM pitches: the high four bits hold the octave, the low four the note. | |
| struct SoundWork | gSound_Work |
| u8 | gSound_WorkBytes [] |
| s32 | gBuildStamp [] |
| The build stamp System_CopyBuildStamp copies to IWRAM at power-on: twelve digits and a zero word, at the bottom of the frame-wait stack. | |
| u8 | gMusicFadeRequested |
| s32 | gSoundClipFlag |
| u8 | gEwram_Data1 |
The sound tables (CGB codes, frequency steps, frame lengths) and the sound routines.
Definition in file sound.h.
| void Audio_ResumeAllPlayers | ( | void | ) |
Resumes every player. Nothing in ☀️ calls it.
Definition at line 219 of file audio.c.
Referenced by Audio_ResumeAllPlayers(), and AudioCommand_ResumeAllPlayers().
| void Audio_ResumePlayer | ( | struct SoundPlayer * | player | ) |
Clears the player's paused flag while holding the player lock.
Called by the resume and play-or-resume commands.
Definition at line 84 of file audio.c.
Referenced by Audio_PlayOrResumeSound(), Audio_ResumeAllPlayers(), Audio_ResumePlayer(), Audio_ResumeSound(), AudioEngine_RunMixerTick(), and MusicPlayer_Resume().
| void Audio_StopAllPlayers | ( | void | ) |
Stops every player. Nothing in ☀️ calls it.
Definition at line 206 of file audio.c.
Referenced by Audio_StopAllPlayers(), and AudioCommand_StopAllPlayers().
| void AudioEngine_Initialize | ( | struct SoundWork * | work | ) |
Resets the sound hardware, clears the whole sound work block and installs the default PCM driver: stores work in SOUND_WORK, points the FIFO DMAs at its two buffers, fills in the driver callbacks and command table, sets the default rate and finally sets the work's lock.
Called by Audio_Initialize.
| void AudioEngine_ResumeDirectSound | ( | void | ) |
Restarts both FIFO transfers and releases the suspended-work lock.
Called by AudioEngine_SetPcmRate.
Definition at line 232 of file engine.c.
Referenced by Audio_UmulHigh32(), AudioEngine_ResumeDirectSound(), AudioEngine_SetPcmRate(), and MusicTrack_HandleNote().
| void AudioEngine_RunMixerTick | ( | void | ) |
| void AudioEngine_SetMode | ( | u32 | mode | ) |
| void AudioEngine_SetPcmRate | ( | u32 | mode | ) |
Sets the PCM frame length (mode bits 16 to 19 pick a gSound_FrameLengths entry) and the rates derived from it, and Timer 0's reload, starting playback at scanline 159.
Called by AudioEngine_Initialize and AudioEngine_SetMode, and by songs through the command table.
| void AudioEngine_SuspendDirectSound | ( | void | ) |
Stops both FIFO transfers and clears their sample buffers, raising the work's lock until AudioEngine_ResumeDirectSound.
Called by AudioEngine_SetMode around a rate change.
Definition at line 213 of file engine.c.
Referenced by AudioEngine_RunMixerTick(), AudioEngine_SetMode(), AudioEngine_SuspendDirectSound(), and MusicTrack_HandleNote().
| void Cgb_UpdateChannels | ( | void | ) |
| void CgbChannel_Mute | ( | u8 | channel | ) |
| void MusicPlayer_BeginFadeOut | ( | struct SoundPlayer * | player, |
| u16 | speed ) |
Begins a fade that stops and clears tracks when its volume reaches zero.
Called by MusicPlayer_FadeOut.
Definition at line 108 of file audio.c.
Referenced by AudioEngine_RunMixerTick(), MusicPlayer_BeginFadeOut(), and MusicPlayer_FadeOut().
| void MusicPlayer_Initialize | ( | struct SoundPlayer * | player, |
| struct SoundTrack * | tracks, | ||
| u8 | count ) |
| void MusicPlayer_StepFade | ( | struct SoundPlayer * | player | ) |
| void MusicPlayer_Stop | ( | struct SoundPlayer * | player | ) |
| void MusicPlayer_Tick | ( | struct SoundPlayer * | player | ) |
| void MusicTrack_CalcOutput | ( | struct SoundPlayer * | player, |
| struct SoundTrack * | track ) |
| void MusicTrack_HandleNote | ( | u32 | command, |
| struct SoundPlayer * | player, | ||
| struct SoundTrack * | track ) |
| void MusicTrack_OperateWorkByte | ( | struct SoundPlayer * | player, |
| struct SoundTrack * | track ) |
| void MusicTrack_ReleaseKey | ( | struct SoundPlayer * | player, |
| struct SoundTrack * | track ) |
| void MusicTrack_SetLfoSpeedFromCommand | ( | struct SoundPlayer * | player, |
| struct SoundTrack * | track ) |
| void MusicTrack_SetModulationFromCommand | ( | struct SoundPlayer * | player, |
| struct SoundTrack * | track ) |
| void MusicTrack_Stop | ( | struct SoundPlayer * | player, |
| struct SoundTrack * | track ) |
| void Sound_Mixer | ( | void | ) |
| void Audio_Initialize | ( | void | ) |
Copies the RAM mixer to IWRAM, initializes the PCM and CGB paths and configures every player from gSound_PlayerSlots.
Called by Audio_InitializeRuntimeDefaults at power-on.
Definition at line 118 of file audio.c.
Referenced by Audio_Initialize(), Audio_InitializeRuntimeDefaults(), and Sound_Mixer().
| void Audio_PlaySound | ( | u16 | songId | ) |
Starts the song on the player selected by its song-table entry.
Called by AudioCommand_Play.
Definition at line 142 of file audio.c.
Referenced by Audio_PlaySound(), AudioCommand_Play(), and Sound_Mixer().
| void Sound_TickDmaRestartTimer | ( | void | ) |
Referenced by MusicPlayer_StepVolumeAndPitchTowardTargets(), and Sound_TickDmaRestartTimer().
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
The build stamp System_CopyBuildStamp copies to IWRAM at power-on: twelve digits and a zero word, at the bottom of the frame-wait stack.
Referenced by AudioTest_RunParameterController(), Sound_Mixer(), and System_CopyBuildStamp().
|
extern |
Referenced by Audio_InitializeRuntimeDefaults(), AudioCommand_Play(), and Sound_Mixer().
|
extern |
Referenced by AudioTest_RunParameterController(), and Sound_Mixer().
|
extern |
Referenced by Audio_InitializeRuntimeDefaults(), and Sound_Mixer().