rename audio context (#1388)

This commit is contained in:
engineer124
2022-10-07 13:43:17 -04:00
committed by GitHub
parent 062f4d8e15
commit 2fb27e6605
13 changed files with 900 additions and 928 deletions
+74 -80
View File
@@ -2200,7 +2200,7 @@ s32 AudioOcarina_MemoryGameNextNote(void) {
}
void AudioOcarina_Update(void) {
sOcarinaUpdateTaskStart = gAudioContext.totalTaskCount;
sOcarinaUpdateTaskStart = gAudioCtx.totalTaskCount;
if (sOcarinaInstrumentId != OCARINA_INSTRUMENT_OFF) {
if (sIsOcarinaInputEnabled == true) {
AudioOcarina_ReadControllerInput();
@@ -2404,7 +2404,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
GfxPrint_Printf(printer, "- %s -", sAudioDebugPageNames[sAudioDebugPage]);
for (i = 0; i < gAudioSpecs[gAudioSpecId].numNotes; i++) {
if (gAudioContext.notes[i].noteSubEu.bitField0.enabled == 1) {
if (gAudioCtx.notes[i].noteSubEu.bitField0.enabled == 1) {
numEnabledNotes++;
}
}
@@ -2529,7 +2529,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
for (k2 = 0; k2 < gChannelsPerBank[gSfxChannelLayout][k]; k2++) {
#define entryIndex (gActiveSfx[k][k2].entryIndex)
#define entry (&gSfxBanks[k][entryIndex])
#define chan (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[entry->channelIdx])
#define chan (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[entry->channelIdx])
GfxPrint_SetPos(printer, 2 + sAudioIntInfoX, 5 + ind + sAudioIntInfoY);
if (sAudioIntInfoBankPage[k] == 1) {
if ((entryIndex != 0xFF) &&
@@ -2692,14 +2692,14 @@ void AudioDebug_Draw(GfxPrint* printer) {
GfxPrint_Printf(printer, "%1X", i);
GfxPrint_SetPos(printer, 15 + i, 7);
if (gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->enabled) {
if (gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->enabled) {
GfxPrint_Printf(printer, "O");
} else {
GfxPrint_Printf(printer, "X");
}
GfxPrint_SetPos(printer, 15 + i, 8);
if (gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->stopSomething2) {
if (gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->stopSomething2) {
GfxPrint_Printf(printer, "O");
} else {
GfxPrint_Printf(printer, "X");
@@ -2708,7 +2708,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
GfxPrint_SetPos(printer, 15 + i, 9);
ctr = 0;
for (j = 0; j < 4; j++) {
if (gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->layers[j] != NULL) {
if (gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->layers[j] != NULL) {
ctr++;
}
}
@@ -2763,33 +2763,32 @@ void AudioDebug_Draw(GfxPrint* printer) {
for (i = 0; i < 8; i++) {
GfxPrint_SetPos(printer, 15 + 3 * i, 22);
GfxPrint_Printf(printer, "%02X ",
(u8)gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
(u8)gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->soundScriptIO[i]);
}
if (gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[sAudioSubTrackInfoChannelSel]->enabled) {
if (gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[sAudioSubTrackInfoChannelSel]->enabled) {
GfxPrint_SetPos(printer, 15, 11);
GfxPrint_Printf(printer, "%d",
(u8)(gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
(u8)(gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->volume *
127.1));
GfxPrint_SetPos(printer, 15, 12);
GfxPrint_Printf(printer, "%d",
(u8)(gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
(u8)(gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->volumeScale *
127.1));
GfxPrint_SetPos(printer, 15, 13);
GfxPrint_Printf(printer, "%X",
gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->fontId);
GfxPrint_Printf(
printer, "%X",
gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[sAudioSubTrackInfoChannelSel]->fontId);
ctr = (u8)(gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
ctr = (u8)(gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->instOrWave);
@@ -2805,46 +2804,44 @@ void AudioDebug_Draw(GfxPrint* printer) {
GfxPrint_Printf(printer, "%d", ctr2);
GfxPrint_SetPos(printer, 15, 15);
GfxPrint_Printf(printer, "%d",
gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->newPan);
GfxPrint_Printf(
printer, "%d",
gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[sAudioSubTrackInfoChannelSel]->newPan);
GfxPrint_SetPos(printer, 15, 16);
GfxPrint_Printf(printer, "%d",
gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->panChannelWeight);
GfxPrint_SetPos(printer, 15, 17);
GfxPrint_Printf(printer, "%d",
gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->reverb);
GfxPrint_Printf(
printer, "%d",
gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[sAudioSubTrackInfoChannelSel]->reverb);
GfxPrint_SetPos(printer, 15, 18);
GfxPrint_Printf(printer, "%d",
gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->notePriority);
GfxPrint_SetPos(printer, 15, 19);
GfxPrint_Printf(printer, "%d",
(u8)(gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
(u8)(gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->vibratoRateTarget /
32));
GfxPrint_SetPos(printer, 15, 20);
GfxPrint_Printf(printer, "%d",
(u8)(gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
(u8)(gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->vibratoExtentTarget /
8));
GfxPrint_SetPos(printer, 15, 21);
GfxPrint_Printf(printer, "%d",
(u16)(gAudioContext.seqPlayers[sAudioSubTrackInfoPlayerSel]
(u16)(gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
.channels[sAudioSubTrackInfoChannelSel]
->freqScale *
100));
@@ -2858,47 +2855,46 @@ void AudioDebug_Draw(GfxPrint* printer) {
GfxPrint_SetPos(printer, 3, 5);
GfxPrint_Printf(printer, "DRIVER %05X / %05X",
gAudioContext.miscPool.curRamAddr - gAudioContext.miscPool.startRamAddr,
gAudioContext.miscPool.size);
gAudioCtx.miscPool.curRamAddr - gAudioCtx.miscPool.startRamAddr, gAudioCtx.miscPool.size);
GfxPrint_SetPos(printer, 3, 6);
GfxPrint_Printf(
printer, "AT-SEQ %02X-%02X (%05X-%05X / %05X)", (u8)gAudioContext.seqCache.temporary.entries[0].id,
(u8)gAudioContext.seqCache.temporary.entries[1].id, gAudioContext.seqCache.temporary.entries[0].size,
gAudioContext.seqCache.temporary.entries[1].size, gAudioContext.seqCache.temporary.pool.size);
printer, "AT-SEQ %02X-%02X (%05X-%05X / %05X)", (u8)gAudioCtx.seqCache.temporary.entries[0].id,
(u8)gAudioCtx.seqCache.temporary.entries[1].id, gAudioCtx.seqCache.temporary.entries[0].size,
gAudioCtx.seqCache.temporary.entries[1].size, gAudioCtx.seqCache.temporary.pool.size);
GfxPrint_SetPos(printer, 3, 7);
GfxPrint_Printf(
printer, "AT-BNK %02X-%02X (%05X-%05X / %05X)", (u8)gAudioContext.fontCache.temporary.entries[0].id,
(u8)gAudioContext.fontCache.temporary.entries[1].id, gAudioContext.fontCache.temporary.entries[0].size,
gAudioContext.fontCache.temporary.entries[1].size, gAudioContext.fontCache.temporary.pool.size);
printer, "AT-BNK %02X-%02X (%05X-%05X / %05X)", (u8)gAudioCtx.fontCache.temporary.entries[0].id,
(u8)gAudioCtx.fontCache.temporary.entries[1].id, gAudioCtx.fontCache.temporary.entries[0].size,
gAudioCtx.fontCache.temporary.entries[1].size, gAudioCtx.fontCache.temporary.pool.size);
GfxPrint_SetPos(printer, 3, 8);
GfxPrint_Printf(printer, "ST-SEQ %02Xseqs (%05X / %06X)", gAudioContext.seqCache.persistent.numEntries,
gAudioContext.seqCache.persistent.pool.curRamAddr -
gAudioContext.seqCache.persistent.pool.startRamAddr,
gAudioContext.seqCache.persistent.pool.size);
GfxPrint_Printf(printer, "ST-SEQ %02Xseqs (%05X / %06X)", gAudioCtx.seqCache.persistent.numEntries,
gAudioCtx.seqCache.persistent.pool.curRamAddr -
gAudioCtx.seqCache.persistent.pool.startRamAddr,
gAudioCtx.seqCache.persistent.pool.size);
for (k = 0; (u32)k < gAudioContext.seqCache.persistent.numEntries; k++) {
for (k = 0; (u32)k < gAudioCtx.seqCache.persistent.numEntries; k++) {
GfxPrint_SetPos(printer, 3 + 3 * k, 9);
GfxPrint_Printf(printer, "%02x", gAudioContext.seqCache.persistent.entries[k].id);
GfxPrint_Printf(printer, "%02x", gAudioCtx.seqCache.persistent.entries[k].id);
}
GfxPrint_SetPos(printer, 3, 10);
GfxPrint_Printf(printer, "ST-BNK %02Xbanks (%05X / %06X)", gAudioContext.fontCache.persistent.numEntries,
gAudioContext.fontCache.persistent.pool.curRamAddr -
gAudioContext.fontCache.persistent.pool.startRamAddr,
gAudioContext.fontCache.persistent.pool.size);
GfxPrint_Printf(printer, "ST-BNK %02Xbanks (%05X / %06X)", gAudioCtx.fontCache.persistent.numEntries,
gAudioCtx.fontCache.persistent.pool.curRamAddr -
gAudioCtx.fontCache.persistent.pool.startRamAddr,
gAudioCtx.fontCache.persistent.pool.size);
for (k = 0; (u32)k < gAudioContext.fontCache.persistent.numEntries; k++) {
for (k = 0; (u32)k < gAudioCtx.fontCache.persistent.numEntries; k++) {
GfxPrint_SetPos(printer, 3 + 3 * k, 11);
GfxPrint_Printf(printer, "%02x", gAudioContext.fontCache.persistent.entries[k].id);
GfxPrint_Printf(printer, "%02x", gAudioCtx.fontCache.persistent.entries[k].id);
}
GfxPrint_SetPos(printer, 3, 12);
GfxPrint_Printf(printer, "E-MEM %05X / %05X",
gAudioContext.permanentPool.curRamAddr - gAudioContext.permanentPool.startRamAddr,
gAudioContext.permanentPool.size);
gAudioCtx.permanentPool.curRamAddr - gAudioCtx.permanentPool.startRamAddr,
gAudioCtx.permanentPool.size);
break;
case PAGE_BLOCK_CHANGE_BGM:
@@ -2917,34 +2913,34 @@ void AudioDebug_Draw(GfxPrint* printer) {
SETCOL(255, 255, 255);
GfxPrint_SetPos(printer, 3, 7);
GfxPrint_Printf(printer, "NEXT SCENE %02X %s",
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2],
sAudioSceneNames[(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2]]);
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2],
sAudioSceneNames[(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2]]);
GfxPrint_SetPos(printer, 3, 8);
GfxPrint_Printf(printer, "NOW SCENE %02X %s",
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4],
sAudioSceneNames[(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4]]);
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4],
sAudioSceneNames[(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4]]);
GfxPrint_SetPos(printer, 3, 9);
GfxPrint_Printf(printer, "NOW BLOCK %02X",
(gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[5] + 1) & 0xFF);
(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[5] + 1) & 0xFF);
GfxPrint_SetPos(printer, 3, 11);
GfxPrint_Printf(printer, "PORT");
GfxPrint_SetPos(printer, 3, 12);
GfxPrint_Printf(printer, "%02X %02X %02X %02X",
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[0],
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[1],
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2],
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3]);
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[0],
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[1],
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2],
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3]);
GfxPrint_SetPos(printer, 3, 13);
GfxPrint_Printf(printer, "%02X %02X %02X %02X",
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4],
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[5],
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[6],
(u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[7]);
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4],
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[5],
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[6],
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[7]);
break;
case PAGE_OCARINA_TEST:
@@ -3682,7 +3678,7 @@ void func_800F5CF8(void);
*/
void func_800F3054(void) {
if (func_800FAD34() == 0) {
sAudioUpdateTaskStart = gAudioContext.totalTaskCount;
sAudioUpdateTaskStart = gAudioCtx.totalTaskCount;
sAudioUpdateStartTime = osGetTime();
AudioOcarina_Update();
Audio_StepFreqLerp(&sRiverFreqScaleLerp);
@@ -3700,7 +3696,7 @@ void func_800F3054(void) {
AudioDebug_SetInput();
AudioDebug_ProcessInput();
Audio_ScheduleProcessCmds();
sAudioUpdateTaskEnd = gAudioContext.totalTaskCount;
sAudioUpdateTaskEnd = gAudioCtx.totalTaskCount;
sAudioUpdateEndTime = osGetTime();
}
}
@@ -3774,9 +3770,9 @@ s8 Audio_ComputeSfxReverb(u8 bankId, u8 entryIdx, u8 channelIdx) {
}
}
if (IS_SEQUENCE_CHANNEL_VALID(gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx])) {
scriptAdd = gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->soundScriptIO[1];
if (gAudioContext.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->soundScriptIO[1] < 0) {
if (IS_SEQUENCE_CHANNEL_VALID(gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx])) {
scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->soundScriptIO[1];
if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->soundScriptIO[1] < 0) {
scriptAdd = 0;
}
}
@@ -3843,7 +3839,7 @@ f32 Audio_ComputeSfxFreqScale(u8 bankId, u8 entryIdx) {
f32 freq = 1.0f;
if (entry->sfxParams & SFX_FLAG_14) {
freq = 1.0f - ((gAudioContext.audioRandom & 0xF) / 192.0f);
freq = 1.0f - ((gAudioCtx.audioRandom & 0xF) / 192.0f);
}
switch (bankId) {
@@ -3867,7 +3863,7 @@ f32 Audio_ComputeSfxFreqScale(u8 bankId, u8 entryIdx) {
if (phi_v0 == 1) {
if (!(entry->sfxParams & SFX_FLAG_11)) {
freq *= (1.0293 - ((gAudioContext.audioRandom & 0xF) / 144.0f));
freq *= (1.0293 - ((gAudioCtx.audioRandom & 0xF) / 144.0f));
}
}
@@ -4109,7 +4105,7 @@ void func_800F4010(Vec3f* pos, u16 sfxId, f32 arg2) {
sp24 = 1.0f;
} else {
phi_f0 = 1.1f;
phi_v0 = gAudioContext.audioRandom % 2;
phi_v0 = gAudioCtx.audioRandom % 2;
}
if ((phi_f0 < arg2) && (phi_v0 != 0)) {
@@ -4311,15 +4307,13 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVol) {
// Sets the reverb
for (channelIdx = 0; channelIdx < 16; channelIdx++) {
if (gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx] !=
&gAudioContext.sequenceChannelNone) {
if (gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx] != &gAudioCtx.sequenceChannelNone) {
// soundScriptIO[5] is set to 0x40 in channels 0, 1, and 4
if ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx]->soundScriptIO[5] != 0xFF) {
if ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx]->soundScriptIO[5] != 0xFF) {
// Higher volume leads to lower reverb
reverb =
((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx]->soundScriptIO[5] -
targetVol) +
0x7F;
reverb = ((u16)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx]->soundScriptIO[5] -
targetVol) +
0x7F;
if (reverb > 0x7F) {
reverb = 0x7F;
}
@@ -4495,7 +4489,7 @@ void Audio_SplitBgmChannels(s8 volSplit) {
channelBits = 0;
for (channelIdx = 0; channelIdx < 16; channelIdx++) {
if (notePriority > gAudioContext.seqPlayers[bgmPlayers[i]].channels[channelIdx]->notePriority) {
if (notePriority > gAudioCtx.seqPlayers[bgmPlayers[i]].channels[channelIdx]->notePriority) {
// If the note currently playing in the channel is a high enough priority,
// then keep the channel on by setting a channelBit
// If this condition fails, then the channel will be shut off
@@ -4601,7 +4595,7 @@ void func_800F56A8(void) {
bvar = temp_v0 & 0xFF;
if ((temp_v0 != NA_BGM_DISABLED) && (sSeqFlags[bvar] & SEQ_FLAG_4)) {
if (D_8013062C != 0xC0) {
D_8013062C = gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3];
D_8013062C = gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3];
} else {
D_8013062C = 0;
}