Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
engine.c File Reference

Go to the source code of this file.

Macros

#define SBN_ROM_OFFSET   0xF00000
 
#define TUNE_SCALING_ARR_AMPLIFY_FINE   0
 
#define TUNE_SCALING_ARR_AMPLIFY_COARSE   128
 
#define TUNE_SCALING_ARR_ATTENUATE_FINE   160
 
#define TUNE_SCALING_ARR_ATTENUATE_COARSE   288
 
#define SBN_EXTRA_LOOKUP(i, fmt, e)   (au_fetch_SBN_file(globals->extraFileList[AmbientSoundIDtoMSEQFileIndex[i]], fmt, &e))
 
#define AL_HEADER_SIG_BK   0x424B
 
#define AL_HEADER_SIG_CR   0x4352
 
#define AL_HEADER_SIG_DR   0x4452
 
#define AL_HEADER_SIG_SR   0x5352
 

Enumerations

enum  BKParseState {
  BK_READ_DONE = 0 , BK_READ_FETCH_HEADER = 11 , BK_READ_FETCH_DATA = 21 , BK_READ_SWIZZLE = 31 ,
  BK_READ_PROCESS_CR = 101 , BK_READ_SWIZZLE_CR = 111 , BK_READ_PROCESS_DR = 201 , BK_READ_UNK_DR = 211 ,
  BK_READ_PROCESS_SR = 301 , BK_READ_UNK_SR = 311
}
 

Functions

void au_release_voice (u8 index)
 
void au_engine_init (s32 outputRate)
 
void au_update_clients_for_audio_frame (void)
 Called exactly once per audio frame (every 5.75ms at 32kHz).
 
void au_update_clients_for_video_frame (void)
 this is called once per video frame update (50 or 60 times per second)
 
void au_syn_begin_audio_frame (AuGlobals *globals)
 
void au_reset_nonfree_voice (AuVoice *voice, u8 index)
 
void au_reset_voice (AuVoice *voice, u8 voiceIdx)
 
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_fade_init (Fade *fade, s32 time, s32 startValue, s32 endValue)
 
void au_fade_clear (Fade *fade)
 
void au_fade_update (Fade *fade)
 
void au_fade_set_volume (u8 busID, u16 volume, s32 busVolume)
 
void au_fade_flush (Fade *fade)
 
void au_fade_set_envelope (Fade *fade, s16 value)
 
void au_fade_calc_envelope (Fade *fade, u32 duration, s32 target)
 
void au_fade_update_envelope (Fade *fade)
 
Instrumentau_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 raw access into AuGlobals::bankSets.
 
void au_get_bgm_player_and_file (u32 playerIndex, BGMHeader **outFile, BGMPlayer **outPlayer)
 
void au_get_bgm_player (u32 playerIndex, BGMPlayer **outPlayer)
 
AuResult au_load_song_files (u32 songID, BGMHeader *bgmFile, BGMPlayer *player)
 
AuResult au_reload_song_files (s32 songID, BGMHeader *bgmFile)
 
BGMPlayerau_get_snapshot_by_index (s32 index)
 
AuResult au_ambient_load (u32 ambSoundID)
 
BGMPlayerau_get_client_by_priority (u8 priority)
 
void au_load_INIT (AuGlobals *globals, s32 romAddr, ALHeap *heap)
 
AuResult au_fetch_SBN_file (u32 fileIdx, AuFileFormat format, SBNFileEntry *outEntry)
 
void au_load_PER (AuGlobals *globals, s32 romAddr)
 
void au_load_PRG (AuGlobals *globals, s32 romAddr)
 
s32 au_load_BGM (s32 arg0)
 
InstrumentBankau_get_BK_instruments (BankSet bankSet, u32 bankIndex)
 
BKFileBufferau_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.
 
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 RAM pointers.
 
BKFileBufferau_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), and sets up instrument pointers.
 
s32 au_load_aux_bank (s32 bkFileOffset, s32 bankIndex)
 
void au_clear_instrument_group (s32 bankIndex, BankSet bankSet)
 unused. resets all instruments in (bankIndex, bankSet) to default
 
void au_set_bus_volume_level (s32 soundTypeFlags, u32 volPreset)
 
s32 au_set_reverb_type (s32 soundTypeFlags, s32 reverbType)
 
void au_sync_channel_delay_enabled (u32 bMonoSound)
 
void au_read_rom (s32 romAddr, void *buffer, u32 size)
 
void au_memset (void *dst, s32 size, u8 value)
 
void au_copy_bytes (s8 *src, s8 *dest, s32 size)
 
void au_copy_words (void *src, void *dst, s32 size)
 

Variables

AuCallback BeginSoundUpdateCallback
 
BGMPlayergBGMPlayerA
 
BGMPlayergBGMPlayerB
 
BGMPlayergBGMPlayerC
 
SoundManagergSoundManager
 
AuGlobalsgSoundGlobals
 
AmbienceManagergAuAmbienceManager
 
u16 PerceptualVolumeLevels [9]
 Volume steps use squared values so each level represents linear power increase, matching loudness perception.
 
u8 EnvelopePressDefault []
 
u8 EnvelopeReleaseDefault []
 
f32 AlTuneScaling []
 

Macro Definition Documentation

◆ SBN_ROM_OFFSET

#define SBN_ROM_OFFSET   0xF00000

Definition at line 26 of file engine.c.

Referenced by au_engine_init().

◆ TUNE_SCALING_ARR_AMPLIFY_FINE

#define TUNE_SCALING_ARR_AMPLIFY_FINE   0

Definition at line 401 of file engine.c.

Referenced by au_compute_pitch_ratio().

◆ TUNE_SCALING_ARR_AMPLIFY_COARSE

#define TUNE_SCALING_ARR_AMPLIFY_COARSE   128

Definition at line 402 of file engine.c.

Referenced by au_compute_pitch_ratio().

◆ TUNE_SCALING_ARR_ATTENUATE_FINE

#define TUNE_SCALING_ARR_ATTENUATE_FINE   160

Definition at line 403 of file engine.c.

Referenced by au_compute_pitch_ratio().

◆ TUNE_SCALING_ARR_ATTENUATE_COARSE

#define TUNE_SCALING_ARR_ATTENUATE_COARSE   288

Definition at line 404 of file engine.c.

Referenced by au_compute_pitch_ratio().

◆ SBN_EXTRA_LOOKUP

#define SBN_EXTRA_LOOKUP ( i,
fmt,
e )   (au_fetch_SBN_file(globals->extraFileList[AmbientSoundIDtoMSEQFileIndex[i]], fmt, &e))

Definition at line 663 of file engine.c.

Referenced by au_ambient_load().

◆ AL_HEADER_SIG_BK

#define AL_HEADER_SIG_BK   0x424B

Definition at line 939 of file engine.c.

Referenced by au_load_BK_to_bank(), and au_load_static_BK_to_bank().

◆ AL_HEADER_SIG_CR

#define AL_HEADER_SIG_CR   0x4352

Definition at line 940 of file engine.c.

Referenced by au_load_BK_to_bank(), and au_load_static_BK_to_bank().

◆ AL_HEADER_SIG_DR

#define AL_HEADER_SIG_DR   0x4452

Definition at line 941 of file engine.c.

Referenced by au_load_BK_to_bank().

◆ AL_HEADER_SIG_SR

#define AL_HEADER_SIG_SR   0x5352

Definition at line 942 of file engine.c.

Referenced by au_load_BK_to_bank().

Enumeration Type Documentation

◆ BKParseState

Enumerator
BK_READ_DONE 
BK_READ_FETCH_HEADER 
BK_READ_FETCH_DATA 
BK_READ_SWIZZLE 
BK_READ_PROCESS_CR 
BK_READ_SWIZZLE_CR 
BK_READ_PROCESS_DR 
BK_READ_UNK_DR 
BK_READ_PROCESS_SR 
BK_READ_UNK_SR 

Definition at line 926 of file engine.c.

926 {
927 BK_READ_DONE = 0,
930 BK_READ_SWIZZLE = 31,
931 BK_READ_PROCESS_CR = 101,
932 BK_READ_SWIZZLE_CR = 111,
933 BK_READ_PROCESS_DR = 201,
934 BK_READ_UNK_DR = 211,
935 BK_READ_PROCESS_SR = 301,
936 BK_READ_UNK_SR = 311,
937};
@ BK_READ_SWIZZLE_CR
Definition engine.c:932
@ BK_READ_PROCESS_DR
Definition engine.c:933
@ BK_READ_FETCH_HEADER
Definition engine.c:928
@ BK_READ_UNK_DR
Definition engine.c:934
@ BK_READ_PROCESS_SR
Definition engine.c:935
@ BK_READ_FETCH_DATA
Definition engine.c:929
@ BK_READ_PROCESS_CR
Definition engine.c:931
@ BK_READ_SWIZZLE
Definition engine.c:930
@ BK_READ_DONE
Definition engine.c:927
@ BK_READ_UNK_SR
Definition engine.c:936

Function Documentation

◆ au_release_voice()

void au_release_voice ( u8 index)

Definition at line 29 of file engine.c.

29 {
31
32 voice->cmdPtr = NULL;
33 voice->priority = AU_PRIORITY_FREE;
34}
BSS s32 PopupMenu_SelectedIndex
AuVoice voices[24]
Definition audio.h:1075
@ AU_PRIORITY_FREE
Definition audio.h:133
u8 * cmdPtr
Definition audio.h:846
AuGlobals * gSoundGlobals
Definition engine.c:10

Referenced by au_pull_voice().

◆ au_engine_init()

void au_engine_init ( s32 outputRate)

Definition at line 36 of file engine.c.

36 {
37 AuGlobals* globals;
41 u8 effects[4];
42 u32 i;
43
46
54
55 globals = gSoundGlobals;
56 dummyTrackData = alHeapAlloc(alHeap, 1, 0x8000);
57 globals->dataBGM[0] = (BGMHeader*) &dummyTrackData[0];
58 globals->dataBGM[1] = (BGMHeader*) &dummyTrackData[0x1400];
59 globals->dataMSEQ[0] = (MSEQHeader*) &dummyTrackData[0x1C00];
60 globals->dataMSEQ[1] = (MSEQHeader*) &dummyTrackData[0x1400];
61
62 for (i = 0; i < ARRAY_COUNT(globals->snapshots); i++) {
63 globals->snapshots[i].bgmPlayer = alHeapAlloc(alHeap, 1, sizeof(BGMPlayer));
64 }
65
66 globals->dataSEF = alHeapAlloc(alHeap, 1, 0x5200);
67 globals->defaultInstrument = alHeapAlloc(alHeap, 1, sizeof(Instrument));
68 globals->dataPER = alHeapAlloc(alHeap, 1, 6 * sizeof(PEREntry));
71 globals->outputRate = outputRate;
72 au_reset_instrument(globals->defaultInstrument);
73 au_reset_drum_entry(&globals->defaultDrumEntry);
74 au_reset_instrument_entry(&globals->defaultPRGEntry);
76
77 globals->audioThreadCallbacks[0] = NULL;
78 globals->audioThreadCallbacks[1] = NULL;
79
80 for (i = 0; i < ARRAY_COUNT(globals->snapshots); i++) {
81 globals->snapshots[i].assigned = 0;
82 globals->snapshots[i].priority = 0;
83 }
84
85 for (i = 0; i < ARRAY_COUNT(globals->effectChanges); i++) {
86 globals->effectChanges[i].type = AU_FX_NONE;
87 globals->effectChanges[i].changed = FALSE;
88 }
89
90 for (i = 0; i < ARRAY_COUNT(globals->voices); i++) {
94 voice = &globals->voices[i];
96 voice->pitchRatio = 0;
97 voice->volume = -1;
98 voice->pan = 0xFF;
99 voice->reverb = 0xFF;
100 voice->busID = 0;
101 voice->donePending = FALSE;
102 voice->syncFlags = 0;
103 voice->clientPriority = AU_PRIORITY_FREE;
104 voice->priority = AU_PRIORITY_FREE;
105 }
106
108
109 for (i = 0; i < ARRAY_COUNT(globals->auxBanks); i++) {
110 globals->auxBanks[i] = alHeapAlloc(alHeap, 1, sizeof(BKFileBuffer));
111 }
112
116 effects[2] = -1;
117 effects[3] = -1;
119
121 effects[0] = FX_BUS_BGMB;
122 effects[1] = -1;
123 effects[2] = -1;
124 effects[3] = -1;
126
129 au_init_voices(globals);
130 au_load_BK_headers(globals, alHeap);
132 au_read_rom(fileEntry.offset, globals->dataSEF, fileEntry.data & 0xFFFFFF);
133 }
136 au_load_PER(globals, fileEntry.offset);
137 }
139 au_load_PRG(globals, fileEntry.offset);
140 }
141
142 globals->bankSets[BANK_SET_IDX_0] = globals->auxBankSet;
143 globals->bankSets[BANK_SET_IDX_1] = globals->bankSet2;
144 globals->bankSets[BANK_SET_IDX_2] = globals->defaultBankSet;
145 globals->bankSets[BANK_SET_IDX_3] = globals->musicBankSet;
146 globals->bankSets[BANK_SET_IDX_4] = globals->bankSet4;
147 globals->bankSets[BANK_SET_IDX_5] = globals->bankSet5;
148 globals->bankSets[BANK_SET_IDX_6] = globals->bankSet6;
149 globals->bankSets[BANK_SET_IDX_7] = globals->auxBankSet;
150
152 globals->channelDelayTime = 0;
153 globals->channelDelayBusID = 0;
154 globals->channelDelayPending = FALSE;
155
158}
f32 outputRate
Definition audio.h:1027
u8 channelDelayPending
Definition audio.h:1041
InstrumentBank defaultBankSet[1]
Definition audio.h:1063
InstrumentBank bankSet5[16]
Definition audio.h:1068
SoundManager * soundManager
Definition audio.h:1140
@ AU_FX_NONE
Definition audio.h:155
InstrumentBank bankSet2[16]
Definition audio.h:1066
#define MUS_QUEUE_SIZE
Definition audio.h:107
Instrument * defaultInstrument
Definition audio.h:1028
BKFileBuffer * auxBanks[3]
Definition audio.h:1073
MusicEventTrigger * musicEventQueue
Definition audio.h:1058
struct MSEQHeader * dataMSEQ[2]
Definition audio.h:1048
@ AU_DELAY_CHANNEL_NONE
Definition audio.h:241
AuCallback audioThreadCallbacks[2]
Definition audio.h:1062
InstrumentBank auxBankSet[4]
Definition audio.h:1065
u8 channelDelayBusID
Definition audio.h:1042
@ BANK_SET_IDX_5
Definition audio.h:391
@ BANK_SET_IDX_6
Definition audio.h:392
@ BANK_SET_IDX_7
Definition audio.h:393
@ BANK_SET_IDX_0
Definition audio.h:386
@ BANK_SET_IDX_3
Definition audio.h:389
@ BANK_SET_IDX_1
Definition audio.h:387
@ BANK_SET_IDX_2
Definition audio.h:388
@ BANK_SET_IDX_4
Definition audio.h:390
BGMInstrumentInfo * dataPRG
Definition audio.h:1046
InstrumentBank bankSet6[4]
Definition audio.h:1069
InstrumentBank bankSet4[16]
Definition audio.h:1067
BGMPlayerSnapshot snapshots[1]
Definition audio.h:1049
ALHeap * heap
Definition audio.h:641
@ FX_BUS_BGMA_MAIN
Definition audio.h:234
@ FX_BUS_BGMA_AUX
Definition audio.h:237
@ FX_BUS_SOUND
Definition audio.h:235
@ FX_BUS_BGMB
Definition audio.h:236
AuSynDriver * gSynDriverPtr
Definition syn_driver.c:15
#define PRG_MAX_COUNT
Definition audio.h:119
u8 channelDelaySide
Definition audio.h:1044
Instrument * instrument
Definition audio.h:837
struct BGMHeader * dataBGM[2]
Definition audio.h:1047
PEREntry * dataPER
Definition audio.h:1045
BGMInstrumentInfo defaultPRGEntry
Definition audio.h:1030
struct BGMPlayer * bgmPlayer
Definition audio.h:1020
InstrumentBank * bankSets[8]
Definition audio.h:1070
@ AU_PRIORITY_BGM_PLAYER_MAIN
Definition audio.h:134
@ AU_PRIORITY_MSEQ_MANAGER
Definition audio.h:137
@ AU_PRIORITY_SFX_MANAGER
Definition audio.h:136
@ AU_PRIORITY_BGM_PLAYER_AUX
Definition audio.h:135
AuEffectChange effectChanges[4]
copied from INIT to the audio heap, seems to exist only to find SEF, PER, and PRG
Definition audio.h:1040
AuGlobals * globals
Definition audio.h:1367
SEFHeader * dataSEF
Definition audio.h:1061
u16 * extraFileList
Definition audio.h:1039
InstrumentBank musicBankSet[16]
Definition audio.h:1064
u8 channelDelayTime
Definition audio.h:1043
BGMDrumInfo defaultDrumEntry
Definition audio.h:1029
Represents a dummy BK file large enough to hold everything except the wave data.
Definition audio.h:1008
void au_bgm_player_init(BGMPlayer *player, s32 priority, s32 busID, AuGlobals *globals)
Definition bgm_player.c:523
void au_bgm_set_effect_indices(BGMPlayer *player, u8 *list)
Definition bgm_player.c:601
u32 MusicEventTrigger
void au_pvoice_set_bus(u8 voiceIdx, s8 busID)
Definition syn_driver.c:316
void au_init_voices(AuGlobals *globals)
Initializes all voices in the audio system.
Definition voice.c:19
void au_syn_set_wavetable(u8 voiceIdx, Instrument *table)
Definition syn_driver.c:420
void * alHeapAlloc(ALHeap *heap, s32 count, s32 size)
Definition syn_driver.c:765
void au_init_delay_channel(s16 arg0)
Definition syn_driver.c:732
BGMPlayer * gBGMPlayerB
Definition engine.c:7
void au_load_PRG(AuGlobals *globals, s32 romAddr)
Definition engine.c:837
SoundManager * gSoundManager
Definition engine.c:9
void au_load_INIT(AuGlobals *globals, s32 romAddr, ALHeap *heap)
Definition engine.c:745
#define SBN_ROM_OFFSET
Definition engine.c:26
void au_read_rom(s32 romAddr, void *buffer, u32 size)
Definition engine.c:1209
AuResult au_fetch_SBN_file(u32 fileIdx, AuFileFormat format, SBNFileEntry *outEntry)
Definition engine.c:796
BGMPlayer * gBGMPlayerA
Definition engine.c:6
BGMPlayer * gBGMPlayerC
Definition engine.c:8
void au_load_PER(AuGlobals *globals, s32 romAddr)
Definition engine.c:818
AmbienceManager * gAuAmbienceManager
Definition engine.c:11
@ AU_FMT_PRG
Definition enums.h:1783
@ AU_FMT_PER
Definition enums.h:1782
@ AU_FMT_SEF
Definition enums.h:1780
@ AU_RESULT_OK
Definition enums.h:1759
void au_load_BK_headers(AuGlobals *globals, ALHeap *heap)
Definition load_banks.c:4
void au_mseq_manager_init(AmbienceManager *manager, s8 priority, s8 busID, AuGlobals *globals)
Definition mseq_player.c:44
void au_sfx_load_groups_from_SEF(SoundManager *sndMgr)
Definition sfx_player.c:551
void au_sfx_init(SoundManager *manager, u8 arg1, u8 arg2, AuGlobals *arg3, u8 arg4)
Definition sfx_player.c:466
void snd_notify_engine_ready(ALHeap *heap)
void snd_song_clear_music_events(void)
#define ARRAY_COUNT(arr)
Definition macros.h:40

Referenced by create_audio_system().

◆ au_update_clients_for_audio_frame()

void au_update_clients_for_audio_frame ( void )

Called exactly once per audio frame (every 5.75ms at 32kHz).

this is called per audio frame generated by alAudioFrame (every 184 audio samples) there will be multiuple of these per video frame

Updates MSEQ, SFX, and BGM players for the current audio frame.

Definition at line 210 of file engine.c.

210 {
211 AuGlobals* globals = gSoundGlobals;
214 BGMPlayer* bgmPlayer;
215
217
218 // Update ambience manager every other frame
219 ambManager->nextUpdateCounter -= ambManager->nextUpdateStep;
220 if (ambManager->nextUpdateCounter <= 0) {
221 ambManager->nextUpdateCounter += ambManager->nextUpdateInterval;
223 }
224
225 // Update volume fade for SFX bus
226 if (sfxManager->fadeInfo.baseTicks != 0) {
227 au_fade_update(&sfxManager->fadeInfo);
228 au_fade_set_volume(sfxManager->busID, sfxManager->fadeInfo.baseVolume >> 16, sfxManager->busVolume);
229 }
230
231 // Periodic SFX manager update
232 sfxManager->nextUpdateCounter -= sfxManager->nextUpdateStep;
233 if (sfxManager->nextUpdateCounter <= 0) {
234 sfxManager->nextUpdateCounter += sfxManager->nextUpdateInterval;
236 }
237
238 // Update gBGMPlayerB
240 bgmPlayer = gBGMPlayerB;
241 if (bgmPlayer->fadeInfo.baseTicks != 0) {
242 au_bgm_update_fade(bgmPlayer);
243 }
244 if (bgmPlayer->songName != 0) {
245 bgmPlayer->songPlayingCounter++;
246 }
247
248 bgmPlayer->nextUpdateCounter -= bgmPlayer->nextUpdateStep;
249 if (bgmPlayer->nextUpdateCounter <= 0) {
250 bgmPlayer->nextUpdateCounter += bgmPlayer->tickUpdateInterval;
252 }
253 }
254
255 // Update gBGMPlayerA
257 if (globals->resumeRequested) {
259 }
260 bgmPlayer = gBGMPlayerA;
261 if (bgmPlayer->fadeInfo.envelopeTicks != 0) {
263 if (bgmPlayer->fadeInfo.baseTicks == 0) {
264 au_bgm_update_bus_volumes(bgmPlayer);
265 } else {
266 au_bgm_update_fade(bgmPlayer);
267 }
268 } else if (bgmPlayer->fadeInfo.baseTicks != 0) {
269 au_bgm_update_fade(bgmPlayer);
270 }
271 if (bgmPlayer->songName != 0) {
272 bgmPlayer->songPlayingCounter++;
273 }
274
275 bgmPlayer->nextUpdateCounter -= bgmPlayer->nextUpdateStep;
276 if (bgmPlayer->nextUpdateCounter <= 0) {
277 bgmPlayer->nextUpdateCounter += bgmPlayer->tickUpdateInterval;
279 }
280 }
281
282 // With all clients updated, now update all voices
283 au_update_voices(globals);
284}
s32 songPlayingCounter
video frames (60 fps)
Definition audio.h:1145
s16 baseTicks
Definition audio.h:508
s32 songName
Definition audio.h:1146
s32 nextUpdateCounter
update counter threshold for a single tick
Definition audio.h:1143
s32 nextUpdateStep
Definition audio.h:1141
s32 PreventBGMPlayerUpdate
While TRUE, the audio thread skips BGM player updates.
s16 envelopeTicks
Definition audio.h:513
s32 tickUpdateInterval
update counter amount to add per audio frame
Definition audio.h:1142
Fade fadeInfo
Definition audio.h:1150
b32 resumeRequested
Definition audio.h:1053
s16 prevUpdateResult
Definition audio.h:1157
s32 au_bgm_player_audio_frame_update(BGMPlayer *player)
Definition bgm_player.c:661
void au_bgm_update_bus_volumes(BGMPlayer *player)
Definition bgm_player.c:644
void au_bgm_restore_copied_player(AuGlobals *globals)
Definition bgm_player.c:473
void au_bgm_update_fade(BGMPlayer *player)
Definition bgm_player.c:622
void au_update_voices(AuGlobals *globals)
Main envelope system update, called once per frame.
Definition voice.c:37
void au_fade_update(Fade *fade)
Definition engine.c:438
void au_fade_set_volume(u8 busID, u16 volume, s32 busVolume)
Definition engine.c:453
void au_syn_begin_audio_frame(AuGlobals *globals)
Definition engine.c:308
void au_fade_update_envelope(Fade *fade)
Definition engine.c:489
void au_mseq_manager_audio_frame_update(AmbienceManager *manager)
s16 au_sfx_manager_audio_frame_update(SoundManager *manager)

Referenced by alAudioFrame().

◆ au_update_clients_for_video_frame()

void au_update_clients_for_video_frame ( void )

this is called once per video frame update (50 or 60 times per second)

Definition at line 286 of file engine.c.

286 {
287 AuGlobals* globals = gSoundGlobals;
288 BGMPlayer* player = gBGMPlayerA;
290
291 if (globals->flushMusicEventQueue) {
293 }
294
298 }
299
301
302 player = gBGMPlayerB;
304
306}
s32 flushMusicEventQueue
Definition audio.h:1060
void au_bgm_begin_video_frame(BGMPlayer *player)
Definition bgm_player.c:23
AuCallback BeginSoundUpdateCallback
Definition engine.c:5
void au_sfx_begin_video_frame(SoundManager *manager)
Definition sfx_player.c:618

Referenced by alAudioFrame().

◆ au_syn_begin_audio_frame()

void au_syn_begin_audio_frame ( AuGlobals * globals)

Definition at line 308 of file engine.c.

308 {
309 u32 i;
310
314 }
315
316 if (globals->channelDelayPending && (globals->channelDelayState == AU_DELAY_STATE_ON)) {
317 switch (globals->channelDelaySide) {
321 globals->channelDelayPending = FALSE;
322 break;
326 globals->channelDelayPending = FALSE;
327 break;
328 default:
330 globals->channelDelayPending = FALSE;
331 break;
332 }
333 }
334
335 // handle effect bus changes
336 if (globals->effectChanges[FX_BUS_BGMA_MAIN].changed) {
339 }
340 if (globals->effectChanges[FX_BUS_SOUND].changed) {
343
344 } if (globals->effectChanges[FX_BUS_BGMB].changed) {
347 }
348 if (globals->effectChanges[FX_BUS_BGMA_AUX].changed) {
351 }
352
353 for (i = 0; i < ARRAY_COUNT(globals->voices); i++) {
354 AuVoice* voice = &globals->voices[i];
356
357 if (voice->donePending) {
359 voice->donePending = FALSE;
360 voice->cmdPtr = NULL;
361 voice->priority = AU_PRIORITY_FREE;
362 }
363
365 au_voice_start(voice, &voice->envelope);
366 au_syn_start_voice_params(i, voice->busID, voice->instrument, voice->pitchRatio, voice->volume, voice->pan, voice->reverb, voice->delta);
367 // priority may be AU_PRIORITY_FREE if this voice was stolen and reset
368 voice->priority = voice->clientPriority;
369 } else {
371 au_syn_set_pitch(i, voice->pitchRatio);
372 }
373
375 au_syn_set_mixer_params(i, voice->volume, voice->delta, voice->pan, voice->reverb);
377 au_syn_set_pan_fxmix(i, voice->pan, voice->reverb);
378 }
379 }
380 voice->syncFlags = 0;
381 }
382}
@ AU_DELAY_CHANNEL_LEFT
Definition audio.h:242
@ AU_DELAY_CHANNEL_RIGHT
Definition audio.h:243
@ AU_VOICE_SYNC_FLAG_PARAMS
Definition audio.h:149
@ AU_VOICE_SYNC_FLAG_PAN_FXMIX
Definition audio.h:151
@ AU_VOICE_SYNC_FLAG_PITCH
Definition audio.h:150
@ AU_VOICE_SYNC_FLAG_ALL
Definition audio.h:148
u8 syncFlags
Definition audio.h:863
u8 channelDelayState
Definition audio.h:1071
@ AU_DELAY_STATE_OFF
channel delay is enabled (though not necessarily applied)
Definition audio.h:248
@ AU_DELAY_STATE_ON
Definition audio.h:247
@ AU_DELAY_STATE_REQUEST_OFF
channel delay is disabled
Definition audio.h:249
void au_disable_channel_delay(void)
Definition syn_driver.c:726
void au_syn_stop_voice(u8 voiceIdx)
Definition syn_driver.c:323
void au_delay_left_channel(u8 arg0)
Definition syn_driver.c:696
void au_delay_right_channel(u8 arg0)
Definition syn_driver.c:711
void au_syn_start_voice_params(u8 index, u8 reverbType, Instrument *table, f32 pitch, s16 vol, u8 pan, u8 fxMix, s32 delta)
Definition syn_driver.c:357
void au_syn_set_pan_fxmix(u8 voiceIdx, u8 arg1, u8 arg2)
Definition syn_driver.c:497
void au_voice_start(AuVoice *voice, EnvelopeData *envData)
Starts a new voice with the given envelope data.
Definition voice.c:187
void au_bus_set_effect(u8 busID, u8 effectID)
Definition syn_driver.c:301
void au_set_delay_time(s32 arg0)
Definition syn_driver.c:684
void au_syn_set_pitch(u8 voiceIdx, f32 pitchRatio)
Definition syn_driver.c:458
void au_syn_set_mixer_params(u8 voiceIdx, s16 volume, s32 arg2, u8 arg3, u8 arg4)
Definition syn_driver.c:464

Referenced by au_update_clients_for_audio_frame().

◆ au_reset_nonfree_voice()

void au_reset_nonfree_voice ( AuVoice * voice,
u8 index )

Definition at line 384 of file engine.c.

384 {
385 if (voice->priority != AU_PRIORITY_FREE) {
386 voice->cmdPtr = NULL;
387 voice->donePending = TRUE;
388 voice->syncFlags = 0;
390 }
391}
#define AUDIO_SAMPLES
Definition audio.h:16
void au_syn_set_volume_delta(u8 voiceIdx, s16 arg1, s32 arg2)
Definition syn_driver.c:527

◆ au_reset_voice()

void au_reset_voice ( AuVoice * voice,
u8 voiceIdx )

◆ au_compute_pitch_ratio()

f32 au_compute_pitch_ratio ( s32 tuning)

Converts a linear pitch value (in cents) into a frequency ratio suitable for adjusting playback speed.

This function computes the playback rate corresponding to a pitch shift (up or down) in cents. Positive values increase pitch (higher frequency), and negative values decrease it. Recall 100 cents = 1 semitone, and therefore 1200 cents = 1 octave.

Parameters
tuningThe pitch offset in cents, from +4095 (~ 40.95 semitones up) to -16383 (~ 163.83 semitones down)
Returns
Floating point output rate multiplier. Multiply this with the base sample rate to apply the pitch.

Definition at line 406 of file engine.c.

406 {
407 if (tuning >= 0) {
410 } else {
411 tuning = -tuning;
414 }
415}
#define TUNE_SCALING_ARR_AMPLIFY_COARSE
Definition engine.c:402
#define TUNE_SCALING_ARR_ATTENUATE_COARSE
Definition engine.c:404
#define TUNE_SCALING_ARR_ATTENUATE_FINE
Definition engine.c:403
f32 AlTuneScaling[]
Definition sfx_player.c:378
#define TUNE_SCALING_ARR_AMPLIFY_FINE
Definition engine.c:401

Referenced by au_bgm_player_update_playing(), au_mseq_player_update(), and au_mseq_restore_voices().

◆ au_fade_init()

void au_fade_init ( Fade * fade,
s32 time,
s32 startValue,
s32 endValue )

Definition at line 417 of file engine.c.

417 {
418 fade->baseVolume = startValue << 16;
419 fade->baseTarget = endValue;
420
421 if (time != 0) {
422 fade->baseTicks = (time * 1000) / AU_FRAME_USEC;
423 fade->baseStep = ((endValue << 16) - fade->baseVolume) / fade->baseTicks;
424 } else {
425 fade->baseTicks = 1;
426 fade->baseStep = 0;
427 }
428
429 fade->onCompleteCallback = NULL;
430}
#define AU_FRAME_USEC
Definition audio.h:27

Referenced by au_bgm_process_init_song(), au_bgm_restore_copied_player(), and au_sfx_init().

◆ au_fade_clear()

void au_fade_clear ( Fade * fade)

Definition at line 432 of file engine.c.

432 {
433 fade->baseTicks = 0;
434 fade->baseStep = 0;
435 fade->onCompleteCallback = NULL;
436}

◆ au_fade_update()

void au_fade_update ( Fade * fade)

Definition at line 438 of file engine.c.

438 {
439 fade->baseTicks--;
440
441 if ((fade->baseTicks << 16) != 0) {
442 fade->baseVolume += fade->baseStep;
443 } else {
444 fade->baseVolume = fade->baseTarget << 16;
445 if (fade->onCompleteCallback != NULL) {
446 fade->onCompleteCallback();
447 fade->baseStep = 0;
448 fade->onCompleteCallback = NULL;
449 }
450 }
451}

Referenced by au_update_clients_for_audio_frame().

◆ au_fade_set_volume()

void au_fade_set_volume ( u8 busID,
u16 volume,
s32 busVolume )

Definition at line 453 of file engine.c.

453 {
454 au_bus_set_volume(busID, (u32)(volume * busVolume) / AU_MAX_BUS_VOLUME);
455}
#define AU_MAX_BUS_VOLUME
Definition audio.h:40
void au_bus_set_volume(u8 busID, u16 value)
Definition syn_driver.c:289

Referenced by au_bgm_update_bus_volumes(), au_sfx_init(), and au_update_clients_for_audio_frame().

◆ au_fade_flush()

void au_fade_flush ( Fade * fade)

Definition at line 457 of file engine.c.

457 {
458 if (fade->baseTicks == 0) {
459 fade->baseTicks = 1;
460 fade->baseStep = 0;
461 fade->baseTarget = ((u32)fade->baseVolume >> 16);
462 }
463}

Referenced by au_set_bus_volume_level().

◆ au_fade_set_envelope()

void au_fade_set_envelope ( Fade * fade,
s16 value )

Definition at line 465 of file engine.c.

465 {
466 fade->envelopeVolume = value << 16;
467 fade->envelopeTarget = value;
468 fade->envelopeTicks = 0;
469 fade->envelopeStep = 0;
470}

Referenced by au_bgm_player_init().

◆ au_fade_calc_envelope()

void au_fade_calc_envelope ( Fade * fade,
u32 duration,
s32 target )

Definition at line 472 of file engine.c.

472 {
473 s16 ticks;
474 s32 delta;
475
476 if (duration >= 250 && duration <= 100000) {
477 ticks = (s32)(duration * 1000) / AU_FRAME_USEC;
478 delta = (target << 16) - fade->envelopeVolume;
479
480 fade->envelopeTarget = target;
481 fade->envelopeTicks = ticks;
482 fade->envelopeStep = delta / ticks;
483 } else {
484 fade->envelopeTicks = 0;
485 fade->envelopeStep = 0;
486 }
487}

Referenced by au_bgm_adjust_volume().

◆ au_fade_update_envelope()

void au_fade_update_envelope ( Fade * fade)

Definition at line 489 of file engine.c.

489 {
490 fade->envelopeTicks--;
491
492 if (fade->envelopeTicks != 0) {
493 fade->envelopeVolume += fade->envelopeStep;
494 } else {
495 fade->envelopeStep = 0;
496 fade->envelopeVolume = fade->envelopeTarget << 16;
497 }
498}

Referenced by au_update_clients_for_audio_frame().

◆ au_get_instrument()

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 raw access into AuGlobals::bankSets.

This does not affect values above 3, but 1 and 2 differ.

Definition at line 502 of file engine.c.

502 {
503 // note that patch here can be up to 255, selecting from a maximum of 16 instruments and 16 banks per group
504 Instrument* instrument = (*globals->bankSets[(bank & 0x70) >> 4])[patch];
505 EnvelopePreset* envelope = instrument->envelopes;
506 u32 envelopeIdx = bank & 3;
507
508 if (envelopeIdx < envelope->count) {
509 envData->cmdListPress = AU_FILE_RELATIVE(envelope, envelope->offsets[envelopeIdx].offsetPress);
510 envData->cmdListRelease = AU_FILE_RELATIVE(envelope, envelope->offsets[envelopeIdx].offsetRelease);
511 } else {
512 envData->cmdListPress = EnvelopePressDefault;
513 envData->cmdListRelease = &EnvelopePressDefault[4]; //EnvelopeReleaseDefault;
514 }
515 return instrument;
516}
EnvelopeOffset offsets[1]
Definition audio.h:670
u16 offsetPress
Definition audio.h:663
#define AU_FILE_RELATIVE(base, offset)
Definition audio.h:43
EnvelopePreset * envelopes
Definition audio.h:696
u16 offsetRelease
Definition audio.h:664
u8 EnvelopePressDefault[]
Definition sfx_player.c:317

Referenced by au_bgm_player_update_playing(), au_BGMCmd_E8_TrackOverridePatch(), au_BGMCmd_F5_UseInstrument(), and au_mseq_player_update().

◆ au_get_bgm_player_and_file()

void au_get_bgm_player_and_file ( u32 playerIndex,
BGMHeader ** outFile,
BGMPlayer ** outPlayer )

Definition at line 518 of file engine.c.

518 {
519 AuGlobals* globals = gSoundGlobals;
520
521 switch (playerIndex) {
522 case 0:
523 *outFile = globals->dataBGM[0];
525 break;
526 case 1:
527 *outFile = globals->dataBGM[1];
529 break;
530 case 2:
531 *outFile = globals->dataBGM[0];
533 break;
534 default:
535 *outFile = NULL;
536 *outPlayer = NULL;
537 break;
538 }
539}

Referenced by snd_song_load().

◆ au_get_bgm_player()

void au_get_bgm_player ( u32 playerIndex,
BGMPlayer ** outPlayer )

Definition at line 541 of file engine.c.

541 {
542 switch (playerIndex) {
543 case 0:
545 break;
546 case 1:
548 break;
549 case 2:
551 break;
552 default:
553 *outPlayer = NULL;
554 break;
555 }
556}

◆ au_load_song_files()

AuResult au_load_song_files ( u32 songID,
BGMHeader * bgmFile,
BGMPlayer * player )

Definition at line 558 of file engine.c.

558 {
559 AuResult status;
563 AuGlobals* globals = gSoundGlobals;
565 s32 i;
566 u16 bkFileIndex;
567 s32 bgmFileIndex;
568 u32 data;
569 u32 offset;
572 s32 cond;
573
574 // needed to match
575 cond = songID < globals->songListLength;
576 playerCopy = player;
577 fileCopy = bgmFile;
578
579 if (cond) {
580 songInfo = &globals->songList[songID];
581 status = au_fetch_SBN_file(songInfo->bgmFileIndex, AU_FMT_BGM, &fileEntry);
582 if (status != AU_RESULT_OK) {
583 return status;
584 }
585
587 return AU_ERROR_201;
588 }
589
590 au_read_rom(fileEntry.offset, fileCopy, fileEntry.data & 0xFFFFFF);
591
592 for (i = 0; i < ARRAY_COUNT(songInfo->bkFileIndex); i++) {
593 bkFileIndex = songInfo->bkFileIndex[i];
594 if (bkFileIndex != 0) {
595 bkFileEntry = &globals->sbnFileList[bkFileIndex];
596
597 offset = (bkFileEntry->offset & 0xFFFFFF) + globals->baseRomOffset;
598 fileEntry2.offset = offset;
599
600 data = bkFileEntry->data;
601 fileEntry2.data = data;
602
603 if ((data >> 0x18) == AU_FMT_BK) {
604 au_load_aux_bank(offset, i);
605 }
606 }
607 }
608 bgmFileIndex = songInfo->bgmFileIndex;
609 playerCopy->songID = songID;
610 playerCopy->bgmFile = bgmFile;
611 playerCopy->bgmFileIndex = bgmFileIndex;
612 return fileCopy->name;
613 } else {
614 return AU_ERROR_151;
615 }
616}
s32 baseRomOffset
Definition audio.h:1031
InitSongEntry * songList
Definition audio.h:1035
SBNFileEntry * sbnFileList
Definition audio.h:1032
s32 name
Definition audio.h:882
s32 songListLength
copied from INIT to the audio heap
Definition audio.h:1036
b32 au_bgm_player_is_active(BGMPlayer *player)
Definition bgm_player.c:279
s32 au_load_aux_bank(s32 bkFileOffset, s32 bankIndex)
Definition engine.c:1150
@ AU_FMT_BGM
Definition enums.h:1779
@ AU_FMT_BK
Definition enums.h:1781
AuResult
Definition enums.h:1758
@ AU_ERROR_151
Definition enums.h:1774
@ AU_ERROR_201
Definition enums.h:1775

Referenced by snd_song_load().

◆ au_reload_song_files()

AuResult au_reload_song_files ( s32 songID,
BGMHeader * bgmFile )

Definition at line 618 of file engine.c.

618 {
619 AuResult status;
623 AuGlobals* globals;
625 s32 i;
626 u16 bkFileIndex;
627
628 globals = gSoundGlobals;
629 songInfo = &globals->songList[songID];
630 status = au_fetch_SBN_file(songInfo->bgmFileIndex, AU_FMT_BGM, &sbnEntry);
631 if (status == AU_RESULT_OK) {
632 // load BGM file
633 au_read_rom(sbnEntry.offset, bgmFile, sbnEntry.data & 0xFFFFFF);
634
635 // load any auxiliary banks required by this BGM
636 for (i = 0; i < ARRAY_COUNT(songInfo->bkFileIndex); i++) {
637 bkFileIndex = songInfo->bkFileIndex[i];
638 if (bkFileIndex != 0) {
639 bkFileEntry = &globals->sbnFileList[bkFileIndex];
640
641 fileEntry.offset = (bkFileEntry->offset & 0xFFFFFF) + globals->baseRomOffset;
642 fileEntry.data = bkFileEntry->data;
643
644 if ((fileEntry.data >> 0x18) == AU_FMT_BK) {
645 au_load_aux_bank(fileEntry.offset, i);
646 } else {
648 }
649 }
650 }
651 }
652
653 return status;
654}
s32 offset
Definition audio.h:916
@ AU_ERROR_SBN_FORMAT_MISMATCH
Definition enums.h:1773

Referenced by au_bgm_process_resume().

◆ au_get_snapshot_by_index()

BGMPlayer * au_get_snapshot_by_index ( s32 index)

Definition at line 656 of file engine.c.

656 {
657 if (index == BGM_SNAPSHOT_0) {
659 }
660 return NULL;
661}
@ BGM_SNAPSHOT_0
Definition audio.h:192

Referenced by au_bgm_process_resume(), and au_bgm_process_suspend().

◆ au_ambient_load()

AuResult au_ambient_load ( u32 ambSoundID)

Definition at line 665 of file engine.c.

665 {
668 AuGlobals* globals;
669 MSEQHeader* mseqFile;
670 u32 i;
671
672 globals = gSoundGlobals;
675 if (manager->players[0].mseqName == 0) {
677 au_read_rom(fileEntry.offset, globals->dataMSEQ[0], fileEntry.data & 0xFFFFFF);
678 manager->mseqFiles[0] = globals->dataMSEQ[0];
679 for (i = 1; i < ARRAY_COUNT(manager->mseqFiles); i++) {
680 manager->mseqFiles[i] = NULL;
681 }
682 manager->numActivePlayers = 1;
683 }
684 }
685 } else if (ambSoundID == AMBIENT_RADIO
686 && manager->players[0].mseqName == 0
687 && manager->players[1].mseqName == 0
688 && manager->players[2].mseqName == 0
689 ) {
690 manager->numActivePlayers = 0;
691 for (i = 0; i < ARRAY_COUNT(manager->mseqFiles); i++) {
692 manager->mseqFiles[i] = NULL;
693 }
694
695 mseqFile = globals->dataMSEQ[1];
697 au_read_rom(fileEntry.offset, mseqFile, fileEntry.data & 0xFFFFFF);
698 manager->mseqFiles[0] = mseqFile;
699
700 mseqFile = AU_FILE_RELATIVE(mseqFile, (fileEntry.data + 0x40) & 0xFFFFFF);
702 au_read_rom(fileEntry.offset, mseqFile, fileEntry.data & 0xFFFFFF);
703 manager->mseqFiles[1] = mseqFile;
704
705 mseqFile = AU_FILE_RELATIVE(mseqFile, (fileEntry.data + 0x40) & 0xFFFFFF);
707 au_read_rom(fileEntry.offset, mseqFile, fileEntry.data & 0xFFFFFF);
708 manager->mseqFiles[2] = mseqFile;
709
710 mseqFile = AU_FILE_RELATIVE(mseqFile, (fileEntry.data + 0x40) & 0xFFFFFF);
712 au_read_rom(fileEntry.offset, mseqFile, fileEntry.data & 0xFFFFFF);
713 manager->mseqFiles[3] = mseqFile;
714
715 manager->numActivePlayers = 4;
717 // @bug perhaps meant to be 3?
718 // the index here corresponds to an entry in gSoundGlobals->banks
719 // 0-2 are used for the extra banks which may be loaded for BGM files
720 // there exists an unused 4th entry this could plausibly be intended for
721 au_load_aux_bank(fileEntry.offset, 2);
722 }
723 }
724 }
725 }
726 }
727 }
728
729 return AU_RESULT_OK;
730}
#define SBN_EXTRA_LOOKUP(i, fmt, e)
Definition engine.c:663
@ AMBIENT_RADIO
Definition enums.h:1921
@ AU_FMT_MSEQ
Definition enums.h:1784

Referenced by snd_load_ambient().

◆ au_get_client_by_priority()

BGMPlayer * au_get_client_by_priority ( u8 priority)

Definition at line 732 of file engine.c.

732 {
733 switch (priority) {
735 return gBGMPlayerA;
737 return gBGMPlayerB;
739 return (BGMPlayer*)gSoundManager; // TODO: why return pointer to SoundManager?
740 default:
741 return NULL;
742 }
743}

Referenced by au_bgm_process_resume().

◆ au_load_INIT()

void au_load_INIT ( AuGlobals * globals,
s32 romAddr,
ALHeap * heap )

Definition at line 745 of file engine.c.

745 {
750 s32 songListOffset, mseqListOffset;
751 s32* data;
752 s32 numEntries;
753 s32* romPtr = &globals->baseRomOffset;
754
756 numEntries = sbnHeader.numEntries;
757 fileListSize = numEntries * sizeof(SBNFileEntry);
758 globals->baseRomOffset = romAddr;
759 globals->fileListLength = sbnHeader.numEntries;
760 globals->sbnFileList = alHeapAlloc(heap, 1, fileListSize);
761 au_read_rom(globals->baseRomOffset + sbnHeader.fileListOffset, globals->sbnFileList, fileListSize);
762
763 entry = globals->sbnFileList;
764 while (sbnHeader.numEntries--) {
765 if ((entry->offset & 0xFFFFFF) == 0) {
766 break;
767 }
768
769 // 16-byte align size
770 size = entry->data;
771 entry->data = (entry->data + 0xF) & ~0xF;
772 entry++;
773 }
774
775 if (sbnHeader.INIToffset != 0) {
776 initBase = *romPtr + sbnHeader.INIToffset;
778
779 songListOffset = initBase + initHeader.songListOffset;
780 size = ALIGN16_(initHeader.songListSize);
781 globals->songList = alHeapAlloc(heap, 1, size);
782 au_read_rom(songListOffset, globals->songList, size);
783
784 mseqListOffset = initBase + initHeader.mseqListOffset;
785 size = ALIGN16_(initHeader.mseqListSize);
786 globals->extraFileList = alHeapAlloc(heap, 1, size);
787 au_read_rom(mseqListOffset, globals->extraFileList, size);
788
789 globals->bkFileListOffset = initBase + initHeader.bankListOffset;
790 globals->bkListLength = ALIGN16_(initHeader.bankListSize);
791
792 globals->songListLength = initHeader.songListSize / sizeof(InitSongEntry) - 1;
793 }
794}
#define ALIGN16_(val)
Definition audio.h:42
s32 bkFileListOffset
Definition audio.h:1037
s32 bkListLength
Definition audio.h:1038
s32 fileListLength
copied from SBN to the audio heap
Definition audio.h:1033

Referenced by au_engine_init().

◆ au_fetch_SBN_file()

AuResult au_fetch_SBN_file ( u32 fileIdx,
AuFileFormat format,
SBNFileEntry * outEntry )

Definition at line 796 of file engine.c.

796 {
798 s32 status = AU_RESULT_OK;
799
800 if (fileIdx < gSoundGlobals->fileListLength) {
802 s32 offset = (entry->offset & 0xFFFFFF) + gSoundGlobals->baseRomOffset;
803
804 fileEntry.offset = offset;
805 fileEntry.data = entry->data;
806 if ((fileEntry.data >> 0x18) == format) {
807 outEntry->offset = offset;
808 outEntry->data = fileEntry.data;
809 } else {
811 }
812 } else {
814 }
815 return status;
816}
@ AU_ERROR_SBN_INDEX_OUT_OF_RANGE
Definition enums.h:1772

Referenced by au_engine_init(), au_load_BK_headers(), au_load_song_files(), and au_reload_song_files().

◆ au_load_PER()

void au_load_PER ( AuGlobals * globals,
s32 romAddr )

Definition at line 818 of file engine.c.

818 {
819 PERHeader header;
820 u32 size;
822 s32 numItems;
823 void* end;
824
825 au_read_rom(romAddr, &header, sizeof(header));
826 size = header.mdata.size - sizeof(header);
827 au_read_rom(romAddr + sizeof(header), globals->dataPER, size);
828 numItems = size / sizeof(PEREntry);
829 numItemsLeft = 6 - numItems;
830 if (numItemsLeft > 0) {
831 end = &globals->dataPER[numItems];
832 au_copy_words(&globals->defaultDrumEntry, end, sizeof(BGMDrumInfo));
833 au_copy_words(end, end + sizeof(BGMDrumInfo), numItemsLeft * sizeof(PEREntry) - sizeof(BGMDrumInfo));
834 }
835}
AUFileMetadata mdata
Definition audio.h:976
void au_copy_words(void *src, void *dst, s32 size)
Definition engine.c:1273

Referenced by au_engine_init().

◆ au_load_PRG()

void au_load_PRG ( AuGlobals * globals,
s32 romAddr )

Definition at line 837 of file engine.c.

837 {
838 PERHeader header;
839 u32 size;
841 s32 numItems;
843 void* end;
844
845 au_read_rom(romAddr, &header, sizeof(header));
846 dataRomAddr = romAddr + sizeof(header);
847 size = header.mdata.size - sizeof(header);
848 if (size > PRG_MAX_COUNT * sizeof(BGMInstrumentInfo)) {
849 size = PRG_MAX_COUNT * sizeof(BGMInstrumentInfo);
850 }
851 au_read_rom(dataRomAddr, globals->dataPRG, size);
852 numItems = size / sizeof(BGMInstrumentInfo);
853 numItemsLeft = PRG_MAX_COUNT - numItems;
854 if (numItemsLeft > 0) {
855 end = &globals->dataPRG[numItems];
856 au_copy_words(&globals->defaultPRGEntry, end, sizeof(BGMInstrumentInfo));
857 au_copy_words(end, end + sizeof(BGMInstrumentInfo), numItemsLeft * sizeof(BGMInstrumentInfo) - sizeof(BGMInstrumentInfo));
858 }
859}

Referenced by au_engine_init().

◆ au_load_BGM()

s32 au_load_BGM ( s32 arg0)

Definition at line 861 of file engine.c.

861 {
862 AuGlobals* globals = gSoundGlobals;
863 InitSongEntry* song = globals->songList;
865 s32 i;
866
867 while (TRUE) {
868 if (song->bgmFileIndex == 0xFFFF) {
869 return ret;
870 }
871
872 if (song->bgmFileIndex == arg0) {
873 for (i = 0; i < ARRAY_COUNT(song->bkFileIndex); i++) {
874 u16 bkFileIndex = song->bkFileIndex[i];
875 if (bkFileIndex != 0) {
876 SBNFileEntry* bkFileEntry = &globals->sbnFileList[bkFileIndex];
878
879 fileEntry.offset = (bkFileEntry->offset & 0xFFFFFF) + globals->baseRomOffset;
880 fileEntry.data = bkFileEntry->data;
881 if ((fileEntry.data >> 0x18) == AU_FMT_BK) {
882 au_load_aux_bank(fileEntry.offset, i);
883 } else {
885 }
886 }
887 }
888
889 return ret;
890 }
891 song++;
892 }
893}
u16 bkFileIndex[3]
Definition audio.h:964

◆ au_get_BK_instruments()

InstrumentBank * au_get_BK_instruments ( BankSet bankSet,
u32 bankIndex )

Definition at line 895 of file engine.c.

895 {
897 AuGlobals* globals = gSoundGlobals;
898
899 // TODO fake match - this multiplying the bankIndex by 16 and then dividing it right after is dumb
900 bankIndex *= 16;
901
902 switch (bankSet) {
903 case BANK_SET_AUX:
904 ret = &globals->auxBankSet[bankIndex / 16];
905 break;
906 case BANK_SET_2:
907 ret = &globals->bankSet2[bankIndex / 16];
908 break;
909 case BANK_SET_4:
910 ret = &globals->bankSet4[bankIndex / 16];
911 break;
912 case BANK_SET_5:
913 ret = &globals->bankSet5[bankIndex / 16];
914 break;
915 case BANK_SET_6:
916 ret = &globals->bankSet6[bankIndex / 16];
917 break;
918 case BANK_SET_MUSIC:
919 ret = &globals->musicBankSet[bankIndex / 16];
920 break;
921 }
922
923 return ret;
924}
@ BANK_SET_2
Definition audio.h:376
@ BANK_SET_AUX
Definition audio.h:375
@ BANK_SET_MUSIC
Definition audio.h:377
@ BANK_SET_6
Definition audio.h:380
@ BANK_SET_5
Definition audio.h:379
@ BANK_SET_4
Definition audio.h:378
Instrument * InstrumentBank[16]
Definition audio.h:699

Referenced by au_clear_instrument_group(), au_load_BK_to_bank(), and au_load_static_BK_to_bank().

◆ au_load_BK_to_bank()

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.

Instruments in the bank will be configured to use DMA streaming for sample/codebook data. This is the standard loader for streamed instrument banks.

Definition at line 947 of file engine.c.

947 {
948 ALHeap* heap = gSynDriverPtr->heap;
950 BKHeader* header = &localHeader;
953 s32 instrumentCount;
956 s32 size;
957 u32 i;
958
959 au_read_rom(bkFileOffset, header, sizeof(*header));
962
963 while (keepReading) {
964 switch (readState) {
965 case BK_READ_DONE:
967 break;
969 if (header->signature != AL_HEADER_SIG_BK) {
971 } else if (header->size == 0) {
973 } else {
975 }
976 break;
978 if (header->format == AL_HEADER_SIG_CR) {
980 } else if (header->format == AL_HEADER_SIG_DR) {
982 } else if (header->format == AL_HEADER_SIG_SR) {
984 } else {
986 }
987 break;
988
990 size = ALIGN16_(header->instrumetsLength)
991 + ALIGN16_(header->loopStatesLength)
992 + ALIGN16_(header->predictorsLength)
993 + ALIGN16_(header->envelopesLength)
994 + sizeof(*header);
995 if (bkFile == NULL) {
996 bkFile = alHeapAlloc(heap, 1, size);
997 }
999
1000 group = au_get_BK_instruments(bankSet, bankIndex);
1001 inst = (*group);
1002 instrumentCount = 0;
1003
1004 for (i = 0; i < ARRAY_COUNT(header->instruments); inst++, i++) {
1005 u16 instOffset = header->instruments[i];
1006 if (instOffset != 0) {
1007 instrumentCount++;
1009 } else {
1010 *inst = NULL;
1011 }
1012 }
1013
1014 if (instrumentCount != 0) {
1016 } else {
1018 }
1019 break;
1020 case BK_READ_SWIZZLE_CR:
1023 break;
1024
1025 // inferred states
1026 case BK_READ_PROCESS_DR:
1027 case BK_READ_UNK_DR:
1028 case BK_READ_PROCESS_SR:
1029 case BK_READ_UNK_SR:
1030 default:
1032 break;
1033 }
1034 }
1035
1036 return bkFile;
1037}
u16 format
Definition audio.h:989
u16 loopStatesLength
Definition audio.h:995
u16 signature
Definition audio.h:985
u16 predictorsLength
Definition audio.h:997
u16 instrumetsLength
Definition audio.h:993
u16 envelopesLength
Definition audio.h:999
s32 size
Definition audio.h:987
u16 instruments[16]
Definition audio.h:992
#define AL_HEADER_SIG_BK
Definition engine.c:939
InstrumentBank * au_get_BK_instruments(BankSet bankSet, u32 bankIndex)
Definition engine.c:895
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...
Definition engine.c:1042
#define AL_HEADER_SIG_DR
Definition engine.c:941
#define AL_HEADER_SIG_CR
Definition engine.c:940
#define AL_HEADER_SIG_SR
Definition engine.c:942

Referenced by au_load_aux_bank(), and au_load_BK_headers().

◆ au_swizzle_BK_instruments()

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 RAM pointers.

Sets whether each instrument uses DMA streaming or not, and updates pitch ratios to match output rate. Replaces NULL instruments with a default instrument to ensure all loaded patches point to valid data.

Definition at line 1042 of file engine.c.

1042 {
1043 Instrument* defaultInstrument = gSoundGlobals->defaultInstrument;
1044 BKHeader* header = &file->header;
1045 f32 outputRate = gSoundGlobals->outputRate;
1046 s32 i;
1047
1048 if (!header->swizzled) {
1049 for (i = 0; i < instrumentCount; i++) {
1050 Instrument* instrument = instruments[i];
1051
1052 if (instrument != NULL) {
1053 if (instrument->wavData != 0) {
1054 instrument->wavData += bkFileOffset;
1055 }
1056 if (instrument->loopState != NULL) {
1057 instrument->loopState = AU_FILE_RELATIVE(file, instrument->loopState);
1058 }
1059 if (instrument->predictor != NULL) {
1060 instrument->predictor = AU_FILE_RELATIVE(file, instrument->predictor);
1061 }
1062 if (instrument->envelopes != NULL) {
1063 instrument->envelopes = AU_FILE_RELATIVE(file, instrument->envelopes);
1064 }
1065 instrument->useDma = useDma;
1066 instrument->pitchRatio = instrument->sampleRate / outputRate;
1067 } else {
1068 instruments[i] = defaultInstrument;
1069 }
1070 }
1071 header->swizzled = TRUE;
1072 }
1073}
ADPCM_STATE * loopState
Definition audio.h:677
s16 * predictor
Definition audio.h:681
b8 useDma
Definition audio.h:689
u8 swizzled
Definition audio.h:990
u8 * wavData
Definition audio.h:675

Referenced by au_load_BK_to_bank(), and au_load_static_BK_to_bank().

◆ au_load_static_BK_to_bank()

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), and sets up instrument pointers.

Instruments are configured to always bypass DMA: sample and codebook data is assumed to be already present in RAM. Use this only for banks whose sample data is guaranteed to be preloaded, not for standard streaming.

Definition at line 1079 of file engine.c.

1079 {
1080 ALHeap* heap = gSynDriverPtr->heap;
1083 BKHeader* header = &localHeader;
1085 Instrument* instruments;
1086 Instrument** inst;
1087 s32 instrumentCount;
1089 u32 readState;
1090 u32 i;
1091 s32 useDma = FALSE;
1092
1094 keepReading = TRUE;
1095
1096 while (keepReading) {
1097 switch (readState) {
1098 case BK_READ_DONE:
1100 break;
1103 if (header->signature != AL_HEADER_SIG_BK) {
1105 } else if (header->size == 0) {
1107 } else if (header->format != AL_HEADER_SIG_CR) {
1109 } else {
1111 }
1112 break;
1113 case BK_READ_FETCH_DATA:
1114 if (bkFile == NULL) {
1115 bkFile = alHeapAlloc(heap, 1, header->size);
1116 }
1117 au_read_rom(*inAddr, bkFile, header->size);
1118
1119 instrumentCount = 0;
1120 group = au_get_BK_instruments(bankSet, bankIndex);
1121 inst = (*group);
1122 for (i = 0; i < ARRAY_COUNT(header->instruments); inst++, i++) {
1123 u16 instOffset = header->instruments[i];
1124 if (instOffset != 0) {
1125 instrumentCount++;
1127 } else {
1128 *inst = NULL;
1129 }
1130 }
1131
1132 if (instrumentCount != 0) {
1134 } else {
1136 }
1137 break;
1138 case BK_READ_SWIZZLE:
1141 break;
1142 default:
1144 break;
1145 }
1146 }
1147 return bkFile;
1148}

◆ au_load_aux_bank()

s32 au_load_aux_bank ( s32 bkFileOffset,
s32 bankIndex )

Definition at line 1150 of file engine.c.

1150 {
1152 return AU_RESULT_OK;
1153}
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.
Definition engine.c:947

Referenced by au_ambient_load(), au_load_BGM(), au_load_song_files(), and au_reload_song_files().

◆ au_clear_instrument_group()

void au_clear_instrument_group ( s32 bankIndex,
BankSet bankSet )

unused. resets all instruments in (bankIndex, bankSet) to default

Definition at line 1156 of file engine.c.

1156 {
1158 InstrumentBank* group = au_get_BK_instruments(bankSet, bankIndex);
1159 Instrument** ptr = *group;
1160 u32 i;
1161
1162 if (group != NULL) {
1163 for (i = 0; i < ARRAY_COUNT(*group); i++) {
1164 *ptr++ = instrument;
1165 }
1166 }
1167}

◆ au_set_bus_volume_level()

void au_set_bus_volume_level ( s32 soundTypeFlags,
u32 volPreset )

Definition at line 1169 of file engine.c.

1169 {
1177 }
1181 }
1182 }
1183}
@ AUDIO_TYPE_BGM
Definition audio.h:398
@ AUDIO_TYPE_SFX
Definition audio.h:399
Fade fadeInfo
Definition audio.h:792
s32 busVolume
Definition audio.h:793
s32 busVolume
Definition audio.h:1151
u16 PerceptualVolumeLevels[9]
Volume steps use squared values so each level represents linear power increase, matching loudness per...
Definition sfx_player.c:299
void au_fade_flush(Fade *fade)
Definition engine.c:457

Referenced by snd_set_bgm_volume(), and snd_set_sfx_volume().

◆ au_set_reverb_type()

s32 au_set_reverb_type ( s32 soundTypeFlags,
s32 reverbType )

Definition at line 1185 of file engine.c.

1185 {
1188 }
1189 return 0;
1190}
s32 au_sfx_set_reverb_type(SoundManager *manager, s32 arg1)
Definition sfx_player.c:719

Referenced by snd_set_sfx_reverb_type().

◆ au_sync_channel_delay_enabled()

void au_sync_channel_delay_enabled ( u32 bMonoSound)

Definition at line 1192 of file engine.c.

1192 {
1193 if (bMonoSound % 2 == 1) {
1194 // mono sound
1197 }
1198 } else {
1199 // stereo sound
1203 }
1204 }
1205}

Referenced by snd_set_mono(), and snd_set_stereo().

◆ au_read_rom()

void au_read_rom ( s32 romAddr,
void * buffer,
u32 size )

Definition at line 1209 of file engine.c.

1209 {
1210 s32 nchunks = size / 0x2000;
1211 s32 offset = 0;
1212
1213 if (nchunks != 0) {
1214 while (nchunks--) {
1215 nuPiReadRom(romAddr + offset, buffer + offset, 0x2000);
1216 offset += 0x2000;
1217 }
1218 }
1219
1220 size %= 0x2000;
1221 if (size != 0) {
1222 nuPiReadRom(romAddr + offset, buffer + offset, size);
1223 }
1224}

Referenced by au_ambient_load(), au_engine_init(), au_load_BK_headers(), au_load_BK_to_bank(), au_load_INIT(), au_load_PER(), au_load_PRG(), au_load_song_files(), au_load_static_BK_to_bank(), and au_reload_song_files().

◆ au_memset()

void au_memset ( void * dst,
s32 size,
u8 value )

Definition at line 1226 of file engine.c.

1226 {
1227 s32 count;
1228 s32 intValue;
1229
1230 if (size == 0) {
1231 return;
1232 }
1233
1234 if (size < 1024) {
1235 while (size--) {
1236 *(u8*)dst++ = value;
1237 }
1238 } else {
1239 count = (u32)dst & 0x3;
1240 if (count != 0) {
1241 count = 4 - count;
1242 size -= count;
1243 while (count--) {
1244 *(u8*)dst++ = value;
1245 }
1246 }
1247
1248 count = size >> 2;
1249 intValue = (value << 8) + value;
1250 intValue = (intValue << 16) + intValue;
1251 while (count--) {
1252 *(u32*)dst = intValue;
1253 dst += 4;
1254 }
1255
1256 count = size & 3;
1257 if (count != 0) {
1258 while (count--) {
1259 *(u8*)dst++ = value;
1260 }
1261 }
1262 }
1263}

Referenced by au_mseq_manager_init(), and au_mseq_play_sequence().

◆ au_copy_bytes()

void au_copy_bytes ( s8 * src,
s8 * dest,
s32 size )

Definition at line 1265 of file engine.c.

1265 {
1266 if (size > 0) {
1267 while (size-- != 0) {
1268 *dest++ = *src++;
1269 }
1270 }
1271}

◆ au_copy_words()

void au_copy_words ( void * src,
void * dst,
s32 size )

Definition at line 1273 of file engine.c.

1273 {
1274 size /= 4;
1275
1276 if (size > 0) {
1277 if (!(((s32) src | (s32) dst) & 3)) {
1278 s32* srcIt = src;
1279 s32* dstIt = dst;
1280
1281 size--;
1282 do {
1283 *dstIt++ = *srcIt++;
1284 } while (size-- != 0);
1285 }
1286 }
1287}

Referenced by au_bgm_process_suspend(), au_bgm_restore_copied_player(), au_load_PER(), and au_load_PRG().

Variable Documentation

◆ BeginSoundUpdateCallback

AuCallback BeginSoundUpdateCallback

Definition at line 5 of file engine.c.

Referenced by au_update_clients_for_video_frame().

◆ gBGMPlayerA

◆ gBGMPlayerB

◆ gBGMPlayerC

BGMPlayer* gBGMPlayerC

Definition at line 8 of file engine.c.

Referenced by au_engine_init().

◆ gSoundManager

◆ gSoundGlobals

◆ gAuAmbienceManager

◆ PerceptualVolumeLevels

u16 PerceptualVolumeLevels[9]
extern

Volume steps use squared values so each level represents linear power increase, matching loudness perception.

This makes each step sound evenly spaced.

Definition at line 299 of file sfx_player.c.

299 {
300 [VOL_LEVEL_MUTE] 0, // 0.0 %
301 [VOL_LEVEL_1] AU_MAX_BUS_VOLUME * SQ(0.125), // 1.5625 %
302 [VOL_LEVEL_2] AU_MAX_BUS_VOLUME * SQ(0.250), // 6.25 %
303 [VOL_LEVEL_3] AU_MAX_BUS_VOLUME * SQ(0.375), // 14.0625 %
304 [VOL_LEVEL_4] AU_MAX_BUS_VOLUME * SQ(0.500), // 25.0 %
305 [VOL_LEVEL_5] AU_MAX_BUS_VOLUME * SQ(0.625), // 39.0625 %
306 [VOL_LEVEL_6] AU_MAX_BUS_VOLUME * SQ(0.750), // 56.25 %
307 [VOL_LEVEL_7] AU_MAX_BUS_VOLUME * SQ(0.875), // 76.5625 %
309};
@ VOL_LEVEL_FULL
Definition enums.h:1822
@ VOL_LEVEL_5
Definition enums.h:1819
@ VOL_LEVEL_2
Definition enums.h:1816
@ VOL_LEVEL_4
Definition enums.h:1818
@ VOL_LEVEL_MUTE
Definition enums.h:1814
@ VOL_LEVEL_6
Definition enums.h:1820
@ VOL_LEVEL_3
Definition enums.h:1817
@ VOL_LEVEL_7
Definition enums.h:1821
@ VOL_LEVEL_1
Definition enums.h:1815
#define SQ(x)
Definition macros.h:178

Referenced by au_set_bus_volume_level().

◆ EnvelopePressDefault

u8 EnvelopePressDefault[]
extern

Definition at line 317 of file sfx_player.c.

317 {
318 ENV_TIME_280MS, 127,
319 ENV_CMD_END, 0
320};
@ ENV_CMD_END
Definition audio.h:257
@ ENV_TIME_280MS
Definition audio.h:322

Referenced by au_get_instrument().

◆ EnvelopeReleaseDefault

u8 EnvelopeReleaseDefault[]
extern

Definition at line 322 of file sfx_player.c.

322 {
324 ENV_CMD_END, 0
325};
@ ENV_TIME_550MS
Definition audio.h:313

◆ AlTuneScaling

f32 AlTuneScaling[]
extern

Definition at line 378 of file sfx_player.c.

378 {
379 // ---------------------------------------------------------
380 // TUNE_SCALING_ARR_AMPLIFY_FINE (offset 0, size 128)
381 // ---------------------------------------------------------
382 // Pitch scaling for fine positive tuning.
383 // Each increment represents a pitch increase of 1 cent (1/100 semitone).
384 //
385 // Formula: 2^((i / 100) / 12) = 2^(i / 1200)
386 // i.e., 1 semitone of amplification at i = 100 (2^(1/12) ~ 1.059463)
387 1.00000000f, 1.00057781f, 1.00115597f, 1.00173450f, 1.00231326f, 1.00289237f, 1.00347185f, 1.00405169f,
388 1.00463188f, 1.00521231f, 1.00579309f, 1.00637424f, 1.00695574f, 1.00753760f, 1.00811982f, 1.00870228f,
389 1.00928509f, 1.00986826f, 1.01045179f, 1.01103568f, 1.01161981f, 1.01220429f, 1.01278913f, 1.01337433f,
390 1.01395988f, 1.01454580f, 1.01513207f, 1.01571858f, 1.01630545f, 1.01689267f, 1.01748025f, 1.01806819f,
391 1.01865649f, 1.01924503f, 1.01983392f, 1.02042317f, 1.02101278f, 1.02160275f, 1.02219307f, 1.02278376f,
392 1.02337468f, 1.02396595f, 1.02455759f, 1.02514958f, 1.02574193f, 1.02633464f, 1.02692771f, 1.02752113f,
393 1.02811480f, 1.02870882f, 1.02930319f, 1.02989793f, 1.03049302f, 1.03108847f, 1.03168428f, 1.03228045f,
394 1.03287685f, 1.03347361f, 1.03407073f, 1.03466821f, 1.03526604f, 1.03586423f, 1.03646278f, 1.03706169f,
395 1.03766096f, 1.03826058f, 1.03886044f, 1.03946066f, 1.04006124f, 1.04066217f, 1.04126346f, 1.04186511f,
396 1.04246712f, 1.04306948f, 1.04367220f, 1.04427528f, 1.04487872f, 1.04548252f, 1.04608655f, 1.04669094f,
397 1.04729569f, 1.04790080f, 1.04850626f, 1.04911208f, 1.04971826f, 1.05032480f, 1.05093169f, 1.05153894f,
398 1.05214655f, 1.05275452f, 1.05336285f, 1.05397153f, 1.05458057f, 1.05518997f, 1.05579972f, 1.05640972f,
399 1.05702007f, 1.05763078f, 1.05824184f, 1.05885327f, 1.05946505f, 1.06007719f, 1.06068969f, 1.06130254f,
400 1.06191576f, 1.06252933f, 1.06314325f, 1.06375754f, 1.06437218f, 1.06498718f, 1.06560254f, 1.06621826f,
401 1.06683433f, 1.06745076f, 1.06806755f, 1.06868470f, 1.06930220f, 1.06992006f, 1.07053828f, 1.07115686f,
402 1.07177579f, 1.07239509f, 1.07301474f, 1.07363474f, 1.07425511f, 1.07487583f, 1.07549691f, 1.07611835f,
403 // ---------------------------------------------------------
404 // TUNE_SCALING_ARR_AMPLIFY_COARSE (offset 128, size 32)
405 // ---------------------------------------------------------
406 // Pitch scaling for coarse positive tuning.
407 // Each increment represents a pitch increase of 128 cents (1.28 semitones)
408 //
409 // Formula: 2^((128 * i / 100) / 12)
410 1.00000000f, 1.07674015f, 1.15936935f, 1.24833953f, 1.34413731f, 1.44728661f, 1.55835164f, 1.67793977f,
411 1.80670512f, 1.94535196f, 2.09463859f, 2.25538135f, 2.42845964f, 2.61482000f, 2.81548166f, 3.03154206f,
412 3.26418304f, 3.51467681f, 3.78439355f, 4.07480860f, 4.38750982f, 4.72420788f, 5.08674431f, 5.47710180f,
413 5.89741516f, 6.34998369f, 6.83728218f, 7.36197615f, 7.92693520f, 8.53524971f, 9.19024563f, 9.89550686f,
414 // ---------------------------------------------------------
415 // TUNE_SCALING_ARR_ATTENUATE_FINE (offset 160, size 128)
416 // ---------------------------------------------------------
417 // Pitch scaling for fine downward tuning.
418 // Each increment represents a pitch decrease of 1 cent (1/100 semitone).
419 //
420 // Formula: 2^(-(i / 100) / 12)
421 1.00000000f, 0.99942255f, 0.99884546f, 0.99826866f, 0.99769223f, 0.99711609f, 0.99654031f, 0.99596488f,
422 0.99538976f, 0.99481499f, 0.99424052f, 0.99366641f, 0.99309260f, 0.99251914f, 0.99194598f, 0.99137318f,
423 0.99080074f, 0.99022859f, 0.98965681f, 0.98908532f, 0.98851418f, 0.98794335f, 0.98737288f, 0.98680270f,
424 0.98623288f, 0.98566335f, 0.98509419f, 0.98452532f, 0.98395681f, 0.98338860f, 0.98282075f, 0.98225319f,
425 0.98168600f, 0.98111910f, 0.98055255f, 0.97998631f, 0.97942042f, 0.97885484f, 0.97828960f, 0.97772467f,
426 0.97716010f, 0.97659582f, 0.97603190f, 0.97546828f, 0.97490501f, 0.97434205f, 0.97377944f, 0.97321713f,
427 0.97265512f, 0.97209346f, 0.97153211f, 0.97097111f, 0.97041041f, 0.96985006f, 0.96929002f, 0.96873033f,
428 0.96817094f, 0.96761185f, 0.96705312f, 0.96649468f, 0.96593660f, 0.96537882f, 0.96482134f, 0.96426421f,
429 0.96370739f, 0.96315092f, 0.96259475f, 0.96203887f, 0.96148336f, 0.96092814f, 0.96037328f, 0.95981872f,
430 0.95926446f, 0.95871055f, 0.95815694f, 0.95760363f, 0.95705068f, 0.95649803f, 0.95594567f, 0.95539367f,
431 0.95484197f, 0.95429057f, 0.95373952f, 0.95318878f, 0.95263839f, 0.95208830f, 0.95153850f, 0.95098901f,
432 0.95043987f, 0.94989103f, 0.94934249f, 0.94879431f, 0.94824642f, 0.94769883f, 0.94715160f, 0.94660467f,
433 0.94605803f, 0.94551176f, 0.94496578f, 0.94442010f, 0.94387472f, 0.94332969f, 0.94278497f, 0.94224054f,
434 0.94169647f, 0.94115269f, 0.94060922f, 0.94006604f, 0.93952322f, 0.93898070f, 0.93843848f, 0.93789655f,
435 0.93735498f, 0.93681371f, 0.93627274f, 0.93573207f, 0.93519175f, 0.93465173f, 0.93411201f, 0.93357259f,
436 0.93303353f, 0.93249476f, 0.93195629f, 0.93141812f, 0.93088025f, 0.93034273f, 0.92980552f, 0.92926860f,
437 // ---------------------------------------------------------
438 // TUNE_SCALING_ARR_ATTENUATE_COARSE (offset 288, size 128)
439 // ---------------------------------------------------------
440 // Pitch scaling for coarse downward tuning.
441 // Each increment represents a pitch decrease of 128 cents (1.28 semitones)
442 //
443 // Formula: 2^(-(128 * i / 100) / 12)
444 1.00000000f, 0.92873198f, 0.86254311f, 0.80107135f, 0.74398059f, 0.69095856f, 0.64171529f, 0.59598154f,
445 0.55350709f, 0.51405972f, 0.47742370f, 0.44339865f, 0.41179851f, 0.38245043f, 0.35519394f, 0.32987997f,
446 0.30637008f, 0.28453568f, 0.26425737f, 0.24542427f, 0.22793336f, 0.21168900f, 0.19660234f, 0.18259089f,
447 0.16957800f, 0.15749252f, 0.14626834f, 0.13584408f, 0.12616274f, 0.11717137f, 0.10882080f, 0.10106535f,
448 0.09386262f, 0.08717322f, 0.08096056f, 0.07519066f, 0.06983197f, 0.06485518f, 0.06023308f, 0.05594039f,
449 0.05195362f, 0.04825099f, 0.04481224f, 0.04161856f, 0.03865249f, 0.03589780f, 0.03333944f, 0.03096340f,
450 0.02875670f, 0.02670727f, 0.02480390f, 0.02303617f, 0.02139443f, 0.01986969f, 0.01845361f, 0.01713846f,
451 0.01591704f, 0.01478266f, 0.01372913f, 0.01275068f, 0.01184197f, 0.01099801f, 0.01021421f, 0.00948626f,
452 0.00881019f, 0.00818231f, 0.00759917f, 0.00705759f, 0.00655461f, 0.00608748f, 0.00565364f, 0.00525071f,
453 0.00487650f, 0.00452897f, 0.00420620f, 0.00390643f, 0.00362802f, 0.00336946f, 0.00312933f, 0.00290631f,
454 0.00269918f, 0.00250681f, 0.00232816f, 0.00216224f, 0.00200814f, 0.00186502f, 0.00173211f, 0.00160866f,
455 0.00149402f, 0.00138754f, 0.00128865f, 0.00119681f, 0.00111152f, 0.00103230f, 0.00095873f, 0.00089041f,
456 0.00082695f, 0.00076801f, 0.00071328f, 0.00066244f, 0.00061523f, 0.00057139f, 0.00053067f, 0.00049285f,
457 0.00045772f, 0.00042510f, 0.00039480f, 0.00036667f, 0.00034054f, 0.00031627f, 0.00029373f, 0.00027279f,
458 0.00025335f, 0.00023530f, 0.00021853f, 0.00020295f, 0.00018849f, 0.00017506f, 0.00016258f, 0.00015099f,
459 0.00014023f, 0.00013024f, 0.00012096f, 0.00011234f, 0.00010433f, 0.00009689f, 0.00008999f, 0.00008358f
460};

Referenced by au_compute_pitch_ratio().