Alchemy
Loading...
Searching...
No Matches

audio_engine_types.h File Reference

The sound driver's types, registers and work. More...

Go to the source code of this file.

Data Structures

struct  SoundVoice
 A voice a track plays its notes with: its kind and base key, the sample or wave it plays, and its attack, decay, sustain and release. More...
struct  SoundNote
 A PCM note, one of 12 the mixer renders: its state and envelope, its output levels, and its links to the other notes of its track. More...
struct  CgbNote
 A note on one of the four CGB channels of the hardware: its state and envelope, its levels and pan, its frequency and its wave. More...
struct  SoundTrack
 A track of a playing song: the song commands it runs, its voice and notes, and the pitch, volume, pan and modulation it gives them. More...
struct  SequenceHeader
 A song's header: its track count, priority and mode, its voices, and where each track's commands start. More...
struct  SoundPlayer
 A player, which plays one song: its header and status, its tracks, its tempo and fade. More...
struct  SoundWork
 The sound driver's work: its lock, the mixer's rate and buffers, the PCM and CGB notes, and the routines the driver calls. More...
struct  PlayerSlot
 An entry of the player table: a player, its tracks and track count, and its priority check. More...
struct  SongEntry
 An entry of the song table: a song's header and the player table entry that plays it. More...

Macros

#define SOUND_LOCK   0x68736D53
#define SOUND_WORK   (*(struct SoundWork **)0x03007FF0)
#define REG_NR10   (*(volatile u8 *)0x04000060)
#define REG_NR11   (*(volatile u8 *)0x04000062)
#define REG_NR12   (*(volatile u8 *)0x04000063)
#define REG_NR13   (*(volatile u8 *)0x04000064)
#define REG_NR14   (*(volatile u8 *)0x04000065)
#define REG_NR21   (*(volatile u8 *)0x04000068)
#define REG_NR22   (*(volatile u8 *)0x04000069)
#define REG_NR23   (*(volatile u8 *)0x0400006c)
#define REG_NR24   (*(volatile u8 *)0x0400006d)
#define REG_NR30   (*(volatile u8 *)0x04000070)
#define REG_NR31   (*(volatile u8 *)0x04000072)
#define REG_NR32   (*(volatile u8 *)0x04000073)
#define REG_NR33   (*(volatile u8 *)0x04000074)
#define REG_NR34   (*(volatile u8 *)0x04000075)
#define REG_NR41   (*(volatile u8 *)0x04000078)
#define REG_NR42   (*(volatile u8 *)0x04000079)
#define REG_NR43   (*(volatile u8 *)0x0400007c)
#define REG_NR44   (*(volatile u8 *)0x0400007d)
#define REG_NR51   (*(volatile u8 *)0x04000081)
#define REG_NR50   (*(volatile u8 *)0x04000080)
#define REG_SOUNDCNT_L   (*(volatile u16 *)0x04000080)
#define REG_SOUNDCNT_X   (*(volatile u16 *)0x04000084)
#define SOUNDCNT_X_ENABLE   0x80
#define SOUNDCNT_X_ALL_TONES_ON   0x0f
#define REG_SOUNDBIAS_H   (*(volatile u8 *)0x04000089)
#define REG_WAVE_RAM   ((volatile u32 *)0x04000090)
#define SOUND_COMMAND_CAST(type, routine)
 Converts between SoundCommand and a table entry that takes other parameters, through the generic function type so neither cast warns.
#define SOUND_FADE_FULL_VOLUME   0x100
#define SOUND_FADE_STEP   16
#define SOUND_COMMAND_FINISH   0
 Entries of gSound_CommandTable, in gSound_CommandTableTemplate's order.
#define SOUND_COMMAND_GOTO   1
 Byte 0xB2: jumps to the address after it.
#define SOUND_COMMAND_WORK_BYTE   8
 Byte 0xB9, installed by CgbAudio_Initialize: an operation, a work byte and an operand; sets, adds to or compares a byte of the player's workBytes (SoundTrackWorkOperation), jumping like GOTO when a comparison holds.
#define SOUND_COMMAND_LFO_SPEED   17
 Byte 0xC2: sets lfoSpeed from the next byte; 0 clears the modulation.
#define SOUND_COMMAND_MODULATION   19
 Byte 0xC4: sets modDepth from the next byte; 0 clears the modulation.
#define SOUND_COMMAND_EXTENDED   28
 Byte 0xCD, installed by CgbAudio_Initialize: runs the entry of gSound_ExtendedCommandTable the next byte names (voice fields, tail level and length).
#define SOUND_COMMAND_RELEASE_KEY   29
 Byte 0xCE: releases the track's sounding note of the key given (or of its last key when no key byte follows).
#define SOUND_COMMAND_PCM_RATE   30
 AudioEngine_SetPcmRate.
#define SOUND_COMMAND_STOP_TRACK   31
 MusicTrack_Stop: silences the track's notes and empties its list.
#define SOUND_COMMAND_FADE   32
 MusicPlayer_StepFade: a frame of a fade.
#define SOUND_COMMAND_CALCULATE_OUTPUT   33
 MusicTrack_CalcOutput.
#define SOUND_COMMAND_DETACH_NOTE   34
 SoundNote_Detach: unlinks a note from its track's list (AudioCommand_InvokeSlot34).
#define SOUND_COMMAND_CLEAR_WORK   35
 SoundDriver_ClearBuffer: zeroes the first 64 bytes of a player or track (AudioCommand_InvokeSlot35).

Enumerations

enum  SoundDriverLimit { SOUND_PCM_NOTE_CAPACITY = 12 , SOUND_CGB_CHANNEL_COUNT = 4 , SOUND_PLAYER_TRACK_LIMIT = 16 }
enum  SoundModulationTarget { SOUND_MODULATION_PITCH , SOUND_MODULATION_VOLUME , SOUND_MODULATION_PAN }
enum  SoundFadeFlag { SOUND_FADE_PAUSE = 1 , SOUND_FADE_IN = 2 }
enum  CgbNoteState {
  CGB_NOTE_PHASE = 0x03 , CGB_NOTE_ECHO = 0x04 , CGB_NOTE_STOP = 0x40 , CGB_NOTE_START = 0x80 ,
  CGB_NOTE_ON = CGB_NOTE_START | CGB_NOTE_STOP | CGB_NOTE_ECHO | CGB_NOTE_PHASE
}
enum  CgbNotePhase { CGB_PHASE_RELEASE , CGB_PHASE_SUSTAIN , CGB_PHASE_DECAY , CGB_PHASE_ATTACK }
enum  CgbNoteModified { CGB_NOTE_VOLUME_DIRTY = 1 , CGB_NOTE_PITCH_DIRTY = 2 }
enum  SoundTrackFlag {
  SOUND_TRACK_VOLUME_DIRTY = 1 , SOUND_TRACK_UPDATE_VOLUME = 3 , SOUND_TRACK_PITCH_DIRTY = 4 , SOUND_TRACK_UPDATE_PITCH = 12 ,
  SOUND_TRACK_RESET = 0x40 , SOUND_TRACK_ACTIVE = 0x80
}
enum  SoundPlayerFlag { SOUND_PLAYER_PAUSED = 0x80000000 }
enum  SoundTrackWorkOperation {
  SOUND_WORK_SET = 0 , SOUND_WORK_ADD , SOUND_WORK_SUBTRACT , SOUND_WORK_COPY ,
  SOUND_WORK_ADD_BYTE , SOUND_WORK_SUBTRACT_BYTE , SOUND_WORK_EQUAL , SOUND_WORK_NOT_EQUAL ,
  SOUND_WORK_GREATER , SOUND_WORK_GREATER_EQUAL , SOUND_WORK_LESS_EQUAL , SOUND_WORK_LESS ,
  SOUND_WORK_EQUAL_BYTE , SOUND_WORK_NOT_EQUAL_BYTE , SOUND_WORK_GREATER_BYTE , SOUND_WORK_GREATER_EQUAL_BYTE ,
  SOUND_WORK_LESS_EQUAL_BYTE , SOUND_WORK_LESS_BYTE
}

Functions

 STATIC_ASSERT (sizeof(struct SoundVoice)==12)
 STATIC_ASSERT (sizeof(struct SoundNote)==64)
 STATIC_ASSERT (sizeof(struct CgbNote)==64)
 STATIC_ASSERT (offsetof(struct CgbNote, frequency)==0x20)
 STATIC_ASSERT (offsetof(struct CgbNote, wave)==0x24)
 STATIC_ASSERT (sizeof(struct SoundTrack)==80)
 STATIC_ASSERT (offsetof(struct SoundTrack, voice)==0x24)
 STATIC_ASSERT (offsetof(struct SoundTrack, cursor)==0x40)
 STATIC_ASSERT (sizeof(struct SoundPlayer)==64)
 STATIC_ASSERT (offsetof(struct SoundWork, cgbNotes)==0x1c)
 STATIC_ASSERT (sizeof(struct SoundWork)==0xfb0)
void CgbAudio_Initialize (struct CgbNote *notes)
 Resets the CGB sound hardware, installs the CGB-aware command handlers and callbacks in the sound work, and clears the four channel records notes.
void CgbNote_UpdatePanEnvelope (struct CgbNote *note)
 Chooses stereo routing and derives peak and sustain levels for a CGB note, writing them into note.
void MusicTrack_ReadVoiceTarget (struct SoundPlayer *player, struct SoundTrack *track)
 Reads an unaligned little-endian voice target address from the sequence.
void MusicTrack_DispatchStreamCommand (struct SoundPlayer *player, struct SoundTrack *track)
 Reads an extended-command index and invokes its handler.
void AudioCommand_InvokeSlot34 (struct SoundNote *note)
 Detaches a note through the command table entry installed by the driver.
void AudioCommand_InvokeSlot35 (void *block)
 Clears a 64-byte player or track prefix through the driver command table.
void MusicPlayer_StartSong (struct SoundPlayer *player, const struct SequenceHeader *header)
 Starts a song when its priority permits, resetting its tracks and tempo.
void MusicPlayer_FadeOut (struct SoundPlayer *player, u16 speed)
 Begins the standard stop-and-clear fade.
void MusicPlayer_SetPitchAndUpdateFrequency (struct SoundPlayer *player, u16 scale)
 Sets the tempo multiplier and updates the number of ticks advanced per frame.
void MusicPlayer_SetVolume (struct SoundPlayer *player, u16 mask, u16 volume)
 Sets the volume scale of active tracks selected by the bit mask and marks their output for recalculation.
void MusicPlayer_SetPitch (struct SoundPlayer *player, u16 mask, s16 pitch)
 Sets the semitone and fractional pitch offsets of selected active tracks and marks their pitch for recalculation.
void MusicPlayer_SetPan (struct SoundPlayer *player, u16 mask, s8 pan)
 Sets the stereo pan offset of selected active tracks.
void MusicPlayer_SetModulationDepth (struct SoundPlayer *player, s32 mask, s32 value)
 Sets modulation depth on selected active tracks, resetting zero-depth modulation.
void MusicPlayer_SetLfoSpeed (struct SoundPlayer *player, u32 mask, u32 value)
 Sets LFO speed on selected active tracks, resetting modulation when stopped.
void MusicTrack_ClearModulation (struct SoundTrack *track)
 Resets the LFO phase and amount, marking the affected output for recalculation.

Variables

const struct PlayerSlot gSound_PlayerSlots []
const struct SongEntry gSound_SongTable []
SoundCommand gSound_CommandTable [36]
const SoundCommand gSound_ExtendedCommandTable []
 Extended commands; entries zero and three do nothing.

Detailed Description

The sound driver's types, registers and work.

Definition in file audio_engine_types.h.

Macro Definition Documentation

◆ SOUND_LOCK

◆ SOUND_WORK

◆ REG_NR10

#define REG_NR10   (*(volatile u8 *)0x04000060)

Definition at line 14 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR11

#define REG_NR11   (*(volatile u8 *)0x04000062)

Definition at line 15 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR12

#define REG_NR12   (*(volatile u8 *)0x04000063)

Definition at line 16 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), CgbAudio_Initialize(), and CgbChannel_Mute().

◆ REG_NR13

#define REG_NR13   (*(volatile u8 *)0x04000064)

Definition at line 17 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR14

#define REG_NR14   (*(volatile u8 *)0x04000065)

Definition at line 18 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), CgbAudio_Initialize(), and CgbChannel_Mute().

◆ REG_NR21

#define REG_NR21   (*(volatile u8 *)0x04000068)

Definition at line 19 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR22

#define REG_NR22   (*(volatile u8 *)0x04000069)

Definition at line 20 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), CgbAudio_Initialize(), and CgbChannel_Mute().

◆ REG_NR23

#define REG_NR23   (*(volatile u8 *)0x0400006c)

Definition at line 21 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR24

#define REG_NR24   (*(volatile u8 *)0x0400006d)

Definition at line 22 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), CgbAudio_Initialize(), and CgbChannel_Mute().

◆ REG_NR30

#define REG_NR30   (*(volatile u8 *)0x04000070)

Definition at line 23 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), CgbAudio_Initialize(), and CgbChannel_Mute().

◆ REG_NR31

#define REG_NR31   (*(volatile u8 *)0x04000072)

Definition at line 24 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR32

#define REG_NR32   (*(volatile u8 *)0x04000073)

Definition at line 25 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR33

#define REG_NR33   (*(volatile u8 *)0x04000074)

Definition at line 26 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR34

#define REG_NR34   (*(volatile u8 *)0x04000075)

Definition at line 27 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR41

#define REG_NR41   (*(volatile u8 *)0x04000078)

Definition at line 28 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR42

#define REG_NR42   (*(volatile u8 *)0x04000079)

Definition at line 29 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), CgbAudio_Initialize(), and CgbChannel_Mute().

◆ REG_NR43

#define REG_NR43   (*(volatile u8 *)0x0400007c)

Definition at line 30 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR44

#define REG_NR44   (*(volatile u8 *)0x0400007d)

Definition at line 31 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), CgbAudio_Initialize(), and CgbChannel_Mute().

◆ REG_NR51

#define REG_NR51   (*(volatile u8 *)0x04000081)

Definition at line 32 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ REG_NR50

#define REG_NR50   (*(volatile u8 *)0x04000080)

Definition at line 34 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ REG_SOUNDCNT_L

#define REG_SOUNDCNT_L   (*(volatile u16 *)0x04000080)

Definition at line 35 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ REG_SOUNDCNT_X

#define REG_SOUNDCNT_X   (*(volatile u16 *)0x04000084)

Definition at line 36 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and CgbAudio_Initialize().

◆ SOUNDCNT_X_ENABLE

#define SOUNDCNT_X_ENABLE   0x80

Definition at line 37 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and CgbAudio_Initialize().

◆ SOUNDCNT_X_ALL_TONES_ON

#define SOUNDCNT_X_ALL_TONES_ON   0x0f

Definition at line 38 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and CgbAudio_Initialize().

◆ REG_SOUNDBIAS_H

#define REG_SOUNDBIAS_H   (*(volatile u8 *)0x04000089)

◆ REG_WAVE_RAM

#define REG_WAVE_RAM   ((volatile u32 *)0x04000090)

Definition at line 40 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ SOUND_COMMAND_CAST

#define SOUND_COMMAND_CAST ( type,
routine )
Value:
((type)(void (*)(void))(routine))

Converts between SoundCommand and a table entry that takes other parameters, through the generic function type so neither cast warns.

Definition at line 52 of file audio_engine_types.h.

Referenced by AudioCommand_InvokeSlot34(), AudioCommand_InvokeSlot35(), and CgbAudio_Initialize().

◆ SOUND_COMMAND_FINISH

#define SOUND_COMMAND_FINISH   0

Entries of gSound_CommandTable, in gSound_CommandTableTemplate's order.

A song byte from 0xB1 to 0xCE runs entry (byte - 0xB1) for its track; bytes from 0xCF up start notes through the work's noteOn instead, so entries 30 to 35 are the driver's helper tail, reached only by its own calls. Unused entries hold MusicTrack_FinishSequence. Byte 0xB1: ends the track, releasing and unlinking its notes.

Definition at line 61 of file audio_engine_types.h.

Referenced by Runtime_CallWorkEntryWithArgs().

◆ SOUND_COMMAND_GOTO

#define SOUND_COMMAND_GOTO   1

Byte 0xB2: jumps to the address after it.

Definition at line 62 of file audio_engine_types.h.

Referenced by MusicTrack_OperateWorkByte().

◆ SOUND_COMMAND_WORK_BYTE

#define SOUND_COMMAND_WORK_BYTE   8

Byte 0xB9, installed by CgbAudio_Initialize: an operation, a work byte and an operand; sets, adds to or compares a byte of the player's workBytes (SoundTrackWorkOperation), jumping like GOTO when a comparison holds.

Definition at line 66 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_LFO_SPEED

#define SOUND_COMMAND_LFO_SPEED   17

Byte 0xC2: sets lfoSpeed from the next byte; 0 clears the modulation.

Definition at line 68 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_MODULATION

#define SOUND_COMMAND_MODULATION   19

Byte 0xC4: sets modDepth from the next byte; 0 clears the modulation.

Definition at line 70 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_EXTENDED

#define SOUND_COMMAND_EXTENDED   28

Byte 0xCD, installed by CgbAudio_Initialize: runs the entry of gSound_ExtendedCommandTable the next byte names (voice fields, tail level and length).

Definition at line 74 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_RELEASE_KEY

#define SOUND_COMMAND_RELEASE_KEY   29

Byte 0xCE: releases the track's sounding note of the key given (or of its last key when no key byte follows).

Definition at line 77 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_PCM_RATE

#define SOUND_COMMAND_PCM_RATE   30

AudioEngine_SetPcmRate.

Definition at line 78 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_STOP_TRACK

#define SOUND_COMMAND_STOP_TRACK   31

MusicTrack_Stop: silences the track's notes and empties its list.

Definition at line 80 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_FADE

#define SOUND_COMMAND_FADE   32

MusicPlayer_StepFade: a frame of a fade.

Definition at line 81 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_CALCULATE_OUTPUT

#define SOUND_COMMAND_CALCULATE_OUTPUT   33

MusicTrack_CalcOutput.

Definition at line 82 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ SOUND_COMMAND_DETACH_NOTE

#define SOUND_COMMAND_DETACH_NOTE   34

SoundNote_Detach: unlinks a note from its track's list (AudioCommand_InvokeSlot34).

Definition at line 85 of file audio_engine_types.h.

Referenced by AudioCommand_InvokeSlot34().

◆ SOUND_COMMAND_CLEAR_WORK

#define SOUND_COMMAND_CLEAR_WORK   35

SoundDriver_ClearBuffer: zeroes the first 64 bytes of a player or track (AudioCommand_InvokeSlot35).

Definition at line 88 of file audio_engine_types.h.

Referenced by AudioCommand_InvokeSlot35().

◆ SOUND_FADE_FULL_VOLUME

#define SOUND_FADE_FULL_VOLUME   0x100

◆ SOUND_FADE_STEP

#define SOUND_FADE_STEP   16

Definition at line 110 of file audio_engine_types.h.

Referenced by MusicPlayer_StepFade().

Enumeration Type Documentation

◆ SoundDriverLimit

Enumerator
SOUND_PCM_NOTE_CAPACITY 

The PCM notes in SoundWork.pcmNotes; mode changes and AudioEngine_StopAllChannels clear all 12, though only pcmNoteCount play.

SOUND_CGB_CHANNEL_COUNT 

CGB channels, numbered 1 to 4.

SOUND_PLAYER_TRACK_LIMIT 

Most tracks a player takes; MusicPlayer_Initialize caps its count here, and the track masks of the MusicPlayer_Set routines are 16 bits.

Definition at line 91 of file audio_engine_types.h.

◆ SoundModulationTarget

Enumerator
SOUND_MODULATION_PITCH 
SOUND_MODULATION_VOLUME 
SOUND_MODULATION_PAN 

Definition at line 101 of file audio_engine_types.h.

◆ SoundFadeFlag

Enumerator
SOUND_FADE_PAUSE 
SOUND_FADE_IN 

Definition at line 107 of file audio_engine_types.h.

◆ CgbNoteState

Enumerator
CGB_NOTE_PHASE 
CGB_NOTE_ECHO 
CGB_NOTE_STOP 
CGB_NOTE_START 
CGB_NOTE_ON 

Definition at line 224 of file audio_engine_types.h.

◆ CgbNotePhase

Enumerator
CGB_PHASE_RELEASE 
CGB_PHASE_SUSTAIN 
CGB_PHASE_DECAY 
CGB_PHASE_ATTACK 

Definition at line 232 of file audio_engine_types.h.

◆ CgbNoteModified

Enumerator
CGB_NOTE_VOLUME_DIRTY 
CGB_NOTE_PITCH_DIRTY 

Definition at line 239 of file audio_engine_types.h.

◆ SoundTrackFlag

Enumerator
SOUND_TRACK_VOLUME_DIRTY 
SOUND_TRACK_UPDATE_VOLUME 
SOUND_TRACK_PITCH_DIRTY 
SOUND_TRACK_UPDATE_PITCH 
SOUND_TRACK_RESET 
SOUND_TRACK_ACTIVE 

Definition at line 241 of file audio_engine_types.h.

◆ SoundPlayerFlag

Enumerator
SOUND_PLAYER_PAUSED 

Definition at line 250 of file audio_engine_types.h.

◆ SoundTrackWorkOperation

Enumerator
SOUND_WORK_SET 
SOUND_WORK_ADD 
SOUND_WORK_SUBTRACT 
SOUND_WORK_COPY 
SOUND_WORK_ADD_BYTE 
SOUND_WORK_SUBTRACT_BYTE 
SOUND_WORK_EQUAL 
SOUND_WORK_NOT_EQUAL 
SOUND_WORK_GREATER 
SOUND_WORK_GREATER_EQUAL 
SOUND_WORK_LESS_EQUAL 
SOUND_WORK_LESS 
SOUND_WORK_EQUAL_BYTE 
SOUND_WORK_NOT_EQUAL_BYTE 
SOUND_WORK_GREATER_BYTE 
SOUND_WORK_GREATER_EQUAL_BYTE 
SOUND_WORK_LESS_EQUAL_BYTE 
SOUND_WORK_LESS_BYTE 

Definition at line 252 of file audio_engine_types.h.

Function Documentation

◆ STATIC_ASSERT() [1/11]

STATIC_ASSERT ( sizeof(struct SoundVoice) = =12)

◆ STATIC_ASSERT() [2/11]

STATIC_ASSERT ( sizeof(struct SoundNote) = =64)

◆ STATIC_ASSERT() [3/11]

STATIC_ASSERT ( sizeof(struct CgbNote) = =64)

◆ STATIC_ASSERT() [4/11]

STATIC_ASSERT ( offsetof(struct CgbNote, frequency) = =0x20)

◆ STATIC_ASSERT() [5/11]

STATIC_ASSERT ( offsetof(struct CgbNote, wave) = =0x24)

◆ STATIC_ASSERT() [6/11]

STATIC_ASSERT ( sizeof(struct SoundTrack) = =80)

◆ STATIC_ASSERT() [7/11]

STATIC_ASSERT ( offsetof(struct SoundTrack, voice) = =0x24)

◆ STATIC_ASSERT() [8/11]

STATIC_ASSERT ( offsetof(struct SoundTrack, cursor) = =0x40)

◆ STATIC_ASSERT() [9/11]

STATIC_ASSERT ( sizeof(struct SoundPlayer) = =64)

◆ STATIC_ASSERT() [10/11]

STATIC_ASSERT ( offsetof(struct SoundWork, cgbNotes) = =0x1c)

◆ STATIC_ASSERT() [11/11]

STATIC_ASSERT ( sizeof(struct SoundWork) = =0xfb0)

◆ CgbAudio_Initialize()

void CgbAudio_Initialize ( struct CgbNote * notes)

Resets the CGB sound hardware, installs the CGB-aware command handlers and callbacks in the sound work, and clears the four channel records notes.

Called by Audio_Initialize.

Definition at line 272 of file audio.c.

Referenced by Audio_Initialize(), CgbAudio_Initialize(), and STATIC_ASSERT().

◆ CgbNote_UpdatePanEnvelope()

void CgbNote_UpdatePanEnvelope ( struct CgbNote * note)

Chooses stereo routing and derives peak and sustain levels for a CGB note, writing them into note.

Called by Cgb_UpdateChannels. Its separate peak calculations and jumps are the form the bytes show: shared, tbs-en is four bytes shorter.

Definition at line 509 of file engine.c.

Referenced by Cgb_UpdateChannels(), CgbNote_UpdatePanEnvelope(), and STATIC_ASSERT().

◆ MusicTrack_ReadVoiceTarget()

void MusicTrack_ReadVoiceTarget ( struct SoundPlayer * player,
struct SoundTrack * track )

Reads an unaligned little-endian voice target address from the sequence.

Definition at line 1078 of file engine.c.

Referenced by MusicTrack_ReadVoiceTarget(), SoundDriver_ClearBuffer(), and STATIC_ASSERT().

◆ MusicTrack_DispatchStreamCommand()

void MusicTrack_DispatchStreamCommand ( struct SoundPlayer * player,
struct SoundTrack * track )

Reads an extended-command index and invokes its handler.

Definition at line 1049 of file engine.c.

Referenced by CgbAudio_Initialize(), MusicTrack_DispatchStreamCommand(), and STATIC_ASSERT().

◆ AudioCommand_InvokeSlot34()

void AudioCommand_InvokeSlot34 ( struct SoundNote * note)

Detaches a note through the command table entry installed by the driver.

Called by the song player (MusicPlayer_Tick, MusicTrack_HandleNote).

Definition at line 7 of file engine.c.

Referenced by AudioCommand_InvokeSlot34(), and STATIC_ASSERT().

◆ AudioCommand_InvokeSlot35()

void AudioCommand_InvokeSlot35 ( void * block)

Clears a 64-byte player or track prefix through the driver command table.

Called by the song player and MusicPlayer_ResetActiveTracks.

Definition at line 19 of file engine.c.

Referenced by AudioCommand_InvokeSlot35(), MusicPlayer_Initialize(), MusicPlayer_ResetActiveTracks(), and STATIC_ASSERT().

◆ MusicPlayer_StartSong()

void MusicPlayer_StartSong ( struct SoundPlayer * player,
const struct SequenceHeader * header )

Starts a song when its priority permits, resetting its tracks and tempo.

Definition at line 282 of file engine.c.

◆ MusicPlayer_FadeOut()

void MusicPlayer_FadeOut ( struct SoundPlayer * player,
u16 speed )

Begins the standard stop-and-clear fade.

Called by AudioCommand_Play's fade cues.

Definition at line 228 of file audio.c.

Referenced by AudioCommand_Play(), MusicPlayer_FadeOut(), and STATIC_ASSERT().

◆ MusicPlayer_SetPitchAndUpdateFrequency()

void MusicPlayer_SetPitchAndUpdateFrequency ( struct SoundPlayer * player,
u16 scale )

Sets the tempo multiplier and updates the number of ticks advanced per frame.

Definition at line 787 of file engine.c.

Referenced by MusicCommand_SetPitchAndUpdateFrequency(), MusicPlayer_SetPitchAndUpdateFrequency(), MusicPlayer_StepVolumeAndPitchTowardTargets(), and STATIC_ASSERT().

◆ MusicPlayer_SetVolume()

void MusicPlayer_SetVolume ( struct SoundPlayer * player,
u16 mask,
u16 volume )

Sets the volume scale of active tracks selected by the bit mask and marks their output for recalculation.

Called by the music layer's volume ramps and commands (sound.c).

Definition at line 800 of file engine.c.

Referenced by AudioCommand_Play(), MusicCommand_SetVolume(), MusicPlayer_SetVolume(), MusicPlayer_StepVolumeAndPitchTowardTargets(), and STATIC_ASSERT().

◆ MusicPlayer_SetPitch()

void MusicPlayer_SetPitch ( struct SoundPlayer * player,
u16 mask,
s16 pitch )

Sets the semitone and fractional pitch offsets of selected active tracks and marks their pitch for recalculation.

Called by the music layer's pitch ramps and commands (sound.c).

Definition at line 828 of file engine.c.

Referenced by MusicCommand_SetPitch(), MusicPlayer_SetPitch(), MusicPlayer_StepVolumeAndPitchTowardTargets(), and STATIC_ASSERT().

◆ MusicPlayer_SetPan()

void MusicPlayer_SetPan ( struct SoundPlayer * player,
u16 mask,
s8 pan )

Sets the stereo pan offset of selected active tracks.

Nothing in ☀️ calls it.

Definition at line 856 of file engine.c.

Referenced by MusicPlayer_SetPan(), and STATIC_ASSERT().

◆ MusicPlayer_SetModulationDepth()

void MusicPlayer_SetModulationDepth ( struct SoundPlayer * player,
s32 mask,
s32 value )

Sets modulation depth on selected active tracks, resetting zero-depth modulation.

Definition at line 894 of file engine.c.

Referenced by MusicPlayer_SetModulationDepth(), and STATIC_ASSERT().

◆ MusicPlayer_SetLfoSpeed()

void MusicPlayer_SetLfoSpeed ( struct SoundPlayer * player,
u32 mask,
u32 value )

Sets LFO speed on selected active tracks, resetting modulation when stopped.

Definition at line 925 of file engine.c.

Referenced by MusicPlayer_SetLfoSpeed(), and STATIC_ASSERT().

◆ MusicTrack_ClearModulation()

void MusicTrack_ClearModulation ( struct SoundTrack * track)

Resets the LFO phase and amount, marking the affected output for recalculation.

Definition at line 883 of file engine.c.

Referenced by MusicPlayer_SetLfoSpeed(), MusicPlayer_SetModulationDepth(), MusicTrack_ClearModulation(), and STATIC_ASSERT().

Variable Documentation

◆ gSound_PlayerSlots

const struct PlayerSlot gSound_PlayerSlots[]
extern

◆ gSound_SongTable

const struct SongEntry gSound_SongTable[]
extern

◆ gSound_CommandTable

SoundCommand gSound_CommandTable[36]
extern

◆ gSound_ExtendedCommandTable

const SoundCommand gSound_ExtendedCommandTable[]
extern

Extended commands; entries zero and three do nothing.

Definition at line 178 of file tables.c.

Referenced by MusicTrack_DispatchStreamCommand(), and STATIC_ASSERT().