20#define SBN_ROM_OFFSET (s32) audio_ROM_START
22#define SBN_ROM_OFFSET 0xFC0000
24#define SBN_ROM_OFFSET 0x13A0000
26#define SBN_ROM_OFFSET 0xF00000
96 voice->pitchRatio = 0;
102 voice->syncFlags = 0;
161static void au_reset_instrument(
Instrument* instrument) {
171 instrument->
type = 0;
180 instrument->pitchRatio = 0.5f;
184static void au_reset_drum_entry(
BGMDrumInfo* info) {
357 if (
voice->donePending) {
380 voice->syncFlags = 0;
388 voice->syncFlags = 0;
396 voice->syncFlags = 0;
401#define TUNE_SCALING_ARR_AMPLIFY_FINE 0
402#define TUNE_SCALING_ARR_AMPLIFY_COARSE 128
403#define TUNE_SCALING_ARR_ATTENUATE_FINE 160
404#define TUNE_SCALING_ARR_ATTENUATE_COARSE 288
441 if ((
fade->baseTicks << 16) != 0) {
444 fade->baseVolume =
fade->baseTarget << 16;
445 if (
fade->onCompleteCallback !=
NULL) {
446 fade->onCompleteCallback();
458 if (
fade->baseTicks == 0) {
466 fade->envelopeVolume = value << 16;
467 fade->envelopeTarget = value;
468 fade->envelopeTicks = 0;
469 fade->envelopeStep = 0;
476 if (duration >= 250 && duration <= 100000) {
478 delta = (
target << 16) -
fade->envelopeVolume;
484 fade->envelopeTicks = 0;
485 fade->envelopeStep = 0;
490 fade->envelopeTicks--;
492 if (
fade->envelopeTicks != 0) {
493 fade->envelopeVolume +=
fade->envelopeStep;
495 fade->envelopeStep = 0;
496 fade->envelopeVolume =
fade->envelopeTarget << 16;
521 switch (playerIndex) {
542 switch (playerIndex) {
593 bkFileIndex =
songInfo->bkFileIndex[i];
594 if (bkFileIndex != 0) {
608 bgmFileIndex =
songInfo->bgmFileIndex;
637 bkFileIndex =
songInfo->bkFileIndex[i];
638 if (bkFileIndex != 0) {
663#define SBN_EXTRA_LOOKUP(i,fmt,e) (au_fetch_SBN_file(globals->extraFileList[AmbientSoundIDtoMSEQFileIndex[i]], fmt, &e))
675 if (
manager->players[0].mseqName == 0) {
686 &&
manager->players[0].mseqName == 0
687 &&
manager->players[1].mseqName == 0
688 &&
manager->players[2].mseqName == 0
698 manager->mseqFiles[0] = mseqFile;
703 manager->mseqFiles[1] = mseqFile;
708 manager->mseqFiles[2] = mseqFile;
713 manager->mseqFiles[3] = mseqFile;
750 s32 songListOffset, mseqListOffset;
765 if ((
entry->offset & 0xFFFFFF) == 0) {
806 if ((
fileEntry.data >> 0x18) == format) {
826 size = header.
mdata.
size -
sizeof(header);
831 end = &globals->
dataPER[numItems];
847 size = header.
mdata.
size -
sizeof(header);
855 end = &globals->
dataPRG[numItems];
868 if (
song->bgmFileIndex == 0xFFFF) {
875 if (bkFileIndex != 0) {
939#define AL_HEADER_SIG_BK 0x424B
940#define AL_HEADER_SIG_CR 0x4352
941#define AL_HEADER_SIG_DR 0x4452
942#define AL_HEADER_SIG_SR 0x5352
971 }
else if (header->
size == 0) {
1002 instrumentCount = 0;
1014 if (instrumentCount != 0) {
1049 for (i = 0; i < instrumentCount; i++) {
1052 if (instrument !=
NULL) {
1053 if (instrument->
wavData != 0) {
1065 instrument->
useDma = useDma;
1066 instrument->pitchRatio = instrument->sampleRate / outputRate;
1068 instruments[i] = defaultInstrument;
1087 s32 instrumentCount;
1105 }
else if (header->
size == 0) {
1119 instrumentCount = 0;
1132 if (instrumentCount != 0) {
1164 *ptr++ = instrument;
1236 *(
u8*)
dst++ = value;
1244 *(
u8*)
dst++ = value;
1259 *(
u8*)
dst++ = value;
1267 while (size-- != 0) {
1284 }
while (size-- != 0);
BSS s32 PopupMenu_SelectedIndex
InstrumentBank defaultBankSet[1]
InstrumentBank bankSet5[16]
SoundManager * soundManager
s32 songPlayingCounter
video frames (60 fps)
InstrumentBank bankSet2[16]
Instrument * defaultInstrument
EnvelopePreset DummyInstrumentEnvelope
BKFileBuffer * auxBanks[3]
MusicEventTrigger * musicEventQueue
struct MSEQHeader * dataMSEQ[2]
EnvelopeOffset offsets[1]
AuCallback audioThreadCallbacks[2]
s32 nextUpdateCounter
update counter threshold for a single tick
#define AU_FILE_RELATIVE(base, offset)
s16 DummyInstrumentCodebook[32]
InstrumentBank auxBankSet[4]
BankSetIndex
The bank indices used by audio assets when choosing an intrument.
BGMInstrumentInfo * dataPRG
BankSet
corresponds with bank group IDs from INIT file bank list (InitBankEntry.bankSet)
SBNFileEntry * sbnFileList
InstrumentBank bankSet6[4]
@ AU_VOICE_SYNC_FLAG_PARAMS
@ AU_VOICE_SYNC_FLAG_PAN_FXMIX
@ AU_VOICE_SYNC_FLAG_PITCH
s32 fileListLength
copied from SBN to the audio heap
InstrumentBank bankSet4[16]
BGMPlayerSnapshot snapshots[1]
s32 PreventBGMPlayerUpdate
While TRUE, the audio thread skips BGM player updates.
s32 tickUpdateInterval
update counter amount to add per audio frame
AuSynDriver * gSynDriverPtr
s32 songListLength
copied from INIT to the audio heap
struct BGMHeader * dataBGM[2]
EnvelopePreset * envelopes
BGMInstrumentInfo defaultPRGEntry
Instrument * InstrumentBank[16]
struct BGMPlayer * bgmPlayer
u8 DummyInstrumentWavData[190]
InstrumentBank * bankSets[8]
@ AU_PRIORITY_BGM_PLAYER_MAIN
@ AU_PRIORITY_MSEQ_MANAGER
@ AU_PRIORITY_SFX_MANAGER
@ AU_PRIORITY_BGM_PLAYER_AUX
AuEffectChange effectChanges[4]
copied from INIT to the audio heap, seems to exist only to find SEF, PER, and PRG
#define AU_MAX_BUS_VOLUME
@ AU_DELAY_STATE_OFF
channel delay is enabled (though not necessarily applied)
@ AU_DELAY_STATE_REQUEST_OFF
channel delay is disabled
InstrumentBank musicBankSet[16]
BGMDrumInfo defaultDrumEntry
Represents a dummy BK file large enough to hold everything except the wave data.
Structure for volume fading for SFX and BGM. Has independent controls for base and envelope volumes.
s32 au_bgm_player_audio_frame_update(BGMPlayer *player)
void au_bgm_update_bus_volumes(BGMPlayer *player)
void au_bgm_restore_copied_player(AuGlobals *globals)
void au_bgm_player_init(BGMPlayer *player, s32 priority, s32 busID, AuGlobals *globals)
b32 au_bgm_player_is_active(BGMPlayer *player)
void au_bgm_begin_video_frame(BGMPlayer *player)
void au_bgm_set_effect_indices(BGMPlayer *player, u8 *list)
void au_bgm_update_fade(BGMPlayer *player)
void au_pvoice_set_bus(u8 voiceIdx, s8 busID)
void au_disable_channel_delay(void)
void au_init_voices(AuGlobals *globals)
Initializes all voices in the audio system.
void au_syn_set_volume_delta(u8 voiceIdx, s16 arg1, s32 arg2)
void au_syn_stop_voice(u8 voiceIdx)
void au_update_voices(AuGlobals *globals)
Main envelope system update, called once per frame.
void au_syn_set_wavetable(u8 voiceIdx, Instrument *table)
void au_delay_left_channel(u8 arg0)
void au_delay_right_channel(u8 arg0)
void au_syn_start_voice_params(u8 index, u8 reverbType, Instrument *table, f32 pitch, s16 vol, u8 pan, u8 fxMix, s32 delta)
void au_syn_set_pan_fxmix(u8 voiceIdx, u8 arg1, u8 arg2)
void au_voice_start(AuVoice *voice, EnvelopeData *envData)
Starts a new voice with the given envelope data.
void au_bus_set_volume(u8 busID, u16 value)
void au_bus_set_effect(u8 busID, u8 effectID)
void au_set_delay_time(s32 arg0)
void au_syn_set_pitch(u8 voiceIdx, f32 pitchRatio)
void au_syn_set_mixer_params(u8 voiceIdx, s16 volume, s32 arg2, u8 arg3, u8 arg4)
void * alHeapAlloc(ALHeap *heap, s32 count, s32 size)
void au_init_delay_channel(s16 arg0)
u8 EnvelopeReleaseDefault[]
u8 EnvelopePressDefault[]
void au_reset_voice(AuVoice *voice, u8 voiceIdx)
void au_fade_set_envelope(Fade *fade, s16 value)
AuResult au_reload_song_files(s32 songID, BGMHeader *bgmFile)
void au_copy_bytes(s8 *src, s8 *dest, s32 size)
void au_get_bgm_player_and_file(u32 playerIndex, BGMHeader **outFile, BGMPlayer **outPlayer)
void au_fade_calc_envelope(Fade *fade, u32 duration, s32 target)
BKFileBuffer * au_load_static_BK_to_bank(s32 *inAddr, void *outAddr, s32 bankIndex, BankSet bankSet)
UNUSED Loads an instrument bank file from ROM to a given buffer (allocates if needed),...
#define TUNE_SCALING_ARR_AMPLIFY_COARSE
#define TUNE_SCALING_ARR_ATTENUATE_COARSE
void au_load_PRG(AuGlobals *globals, s32 romAddr)
#define TUNE_SCALING_ARR_ATTENUATE_FINE
void au_fade_update(Fade *fade)
s32 au_load_aux_bank(s32 bkFileOffset, s32 bankIndex)
SoundManager * gSoundManager
AuGlobals * gSoundGlobals
void au_load_INIT(AuGlobals *globals, s32 romAddr, ALHeap *heap)
void au_engine_init(s32 outputRate)
void au_clear_instrument_group(s32 bankIndex, BankSet bankSet)
unused. resets all instruments in (bankIndex, bankSet) to default
Instrument * au_get_instrument(AuGlobals *globals, BankSetIndex bank, s32 patch, EnvelopeData *envData)
Note that bank is supplied as BankSetIndex and not BankSet, which means it will be used to perform a ...
#define SBN_EXTRA_LOOKUP(i, fmt, e)
f32 au_compute_pitch_ratio(s32 tuning)
Converts a linear pitch value (in cents) into a frequency ratio suitable for adjusting playback speed...
void au_get_bgm_player(u32 playerIndex, BGMPlayer **outPlayer)
void au_fade_set_volume(u8 busID, u16 volume, s32 busVolume)
u16 PerceptualVolumeLevels[9]
Volume steps use squared values so each level represents linear power increase, matching loudness per...
void au_fade_flush(Fade *fade)
void au_read_rom(s32 romAddr, void *buffer, u32 size)
void au_update_clients_for_video_frame(void)
this is called once per video frame update (50 or 60 times per second)
BGMPlayer * au_get_snapshot_by_index(s32 index)
AuResult au_load_song_files(u32 songID, BGMHeader *bgmFile, BGMPlayer *player)
AuResult au_fetch_SBN_file(u32 fileIdx, AuFileFormat format, SBNFileEntry *outEntry)
void au_memset(void *dst, s32 size, u8 value)
AuResult au_ambient_load(u32 ambSoundID)
s32 au_load_BGM(s32 arg0)
void au_fade_init(Fade *fade, s32 time, s32 startValue, s32 endValue)
s32 au_set_reverb_type(s32 soundTypeFlags, s32 reverbType)
void au_update_clients_for_audio_frame(void)
Called exactly once per audio frame (every 5.75ms at 32kHz).
BGMPlayer * au_get_client_by_priority(u8 priority)
#define TUNE_SCALING_ARR_AMPLIFY_FINE
BKFileBuffer * au_load_BK_to_bank(s32 bkFileOffset, BKFileBuffer *bkFile, s32 bankIndex, BankSet bankSet)
Loads an instrument bank file from ROM, allocates memory if needed, and sets up instrument pointers.
InstrumentBank * au_get_BK_instruments(BankSet bankSet, u32 bankIndex)
AuCallback BeginSoundUpdateCallback
void au_load_PER(AuGlobals *globals, s32 romAddr)
void au_swizzle_BK_instruments(s32 bkFileOffset, BKFileBuffer *file, InstrumentBank instruments, u32 instrumentCount, u8 useDma)
Fixes up (swizzles) instrument pointers in a loaded bank, converting file-relative offsets to valid R...
void au_sync_channel_delay_enabled(u32 bMonoSound)
void au_release_voice(u8 index)
void au_syn_begin_audio_frame(AuGlobals *globals)
void au_set_bus_volume_level(s32 soundTypeFlags, u32 volPreset)
void au_copy_words(void *src, void *dst, s32 size)
void au_fade_clear(Fade *fade)
void au_reset_nonfree_voice(AuVoice *voice, u8 index)
AmbienceManager * gAuAmbienceManager
void au_fade_update_envelope(Fade *fade)
@ AU_ERROR_SBN_INDEX_OUT_OF_RANGE
@ AU_ERROR_SBN_FORMAT_MISMATCH
void au_load_BK_headers(AuGlobals *globals, ALHeap *heap)
void au_mseq_manager_init(AmbienceManager *manager, s8 priority, s8 busID, AuGlobals *globals)
void au_mseq_manager_audio_frame_update(AmbienceManager *manager)
s16 au_sfx_manager_audio_frame_update(SoundManager *manager)
void au_sfx_load_groups_from_SEF(SoundManager *sndMgr)
s32 au_sfx_set_reverb_type(SoundManager *manager, s32 arg1)
void au_sfx_init(SoundManager *manager, u8 arg1, u8 arg2, AuGlobals *arg3, u8 arg4)
void au_sfx_begin_video_frame(SoundManager *manager)
void snd_notify_engine_ready(ALHeap *heap)
void snd_song_clear_music_events(void)