exclude audio from shuffle (#2411)

* Rename "SFX Editor" to "Audio Editor"
* Move some functionality out into a new class `AudioCollection`
* Add a tab to exclude sfx/sequences from shuffle pool 

---------

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: briaguya <briaguya>
Co-authored-by: David Chavez <david@dcvz.io>
This commit is contained in:
briaguya 2023-02-16 09:49:45 -05:00 committed by GitHub
commit 1e6ec1bdda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 960 additions and 574 deletions

View file

@ -5,7 +5,7 @@
#include <libultraship/libultra.h>
#include "global.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/sfx-editor/SfxEditor.h"
#include "soh/Enhancements/audio/AudioCollection.h"
#define MK_ASYNC_MSG(retData, tableType, id, status) (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (status))
#define ASYNC_TBLTYPE(v) ((u8)(v >> 16))
@ -487,7 +487,7 @@ u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
if (seqId == NA_BGM_DISABLED)
return NULL;
u16 newSeqId = SfxEditor_GetReplacementSeq(seqId);
u16 newSeqId = AudioEditor_GetReplacementSeq(seqId);
if (newSeqId > MAX_SEQUENCES || !sequenceMap[newSeqId]) {
return NULL;
}
@ -613,7 +613,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) {
AudioSeq_SkipForwardSequence(seqPlayer);
//! @bug missing return (but the return value is not used so it's not UB)
if (CVarGetInteger("gSeqNameOverlay", 0) && playerIdx == SEQ_PLAYER_BGM_MAIN) {
const char* sequenceName = SfxEditor_GetSequenceName(seqId);
const char* sequenceName = AudioCollection_GetSequenceName(seqId);
if (sequenceName != NULL) {
Overlay_DisplayText_Seconds(CVarGetInteger("gSeqNameOverlayDuration", 5), sequenceName);
}
@ -1341,7 +1341,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
for (size_t i = startingSeqNum; i < startingSeqNum + customSeqListSize; i++) {
int j = i - startingSeqNum;
SfxEditor_AddSequence(customSeqList[j], i);
AudioCollection_AddToCollection(customSeqList[j], i);
SequenceData sDat = ResourceMgr_LoadSeqByName(customSeqList[j]);
sDat.seqNumber = i;
@ -1545,7 +1545,7 @@ s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) {
size_t size;
seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId);
u16 newSeqId = SfxEditor_GetReplacementSeq(seqId);
u16 newSeqId = AudioEditor_GetReplacementSeq(seqId);
if (seqId != newSeqId) {
gAudioContext.seqToPlay[SEQ_PLAYER_BGM_MAIN] = newSeqId;
gAudioContext.seqReplaced[SEQ_PLAYER_BGM_MAIN] = 1;

View file

@ -1067,7 +1067,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
seqPlayer->seqId = gAudioContext.seqToPlay[seqPlayer->playerIdx];
gAudioContext.seqReplaced[seqPlayer->playerIdx] = 0;
}
u16 seqId = SfxEditor_GetReplacementSeq(seqPlayer->seqId);
u16 seqId = AudioEditor_GetReplacementSeq(seqPlayer->seqId);
SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[seqId]);
command = sDat.fonts[sDat.numFonts - result - 1];
}
@ -1184,7 +1184,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
seqPlayer->seqId = gAudioContext.seqToPlay[seqPlayer->playerIdx];
gAudioContext.seqReplaced[seqPlayer->playerIdx] = 0;
}
u16 seqId = SfxEditor_GetReplacementSeq(seqPlayer->seqId);
u16 seqId = AudioEditor_GetReplacementSeq(seqPlayer->seqId);
SequenceData sDat = ResourceMgr_LoadSeqByName(sequenceMap[seqId]);
// The game apparantely would sometimes do negative array lookups, the result of which would get rejected by AudioHeap_SearchCaches, never

View file

@ -1700,7 +1700,7 @@ void Audio_OcaSetInstrument(u8 arg0) {
}
u16 sfxEditorId = arg0 + 0x81;
u16 newArg0 = SfxEditor_GetReplacementSeq(sfxEditorId);
u16 newArg0 = AudioEditor_GetReplacementSeq(sfxEditorId);
if (newArg0 != sfxEditorId) {
gAudioContext.seqReplaced[SEQ_PLAYER_SFX] = 1;
arg0 = newArg0 - 0x81;
@ -4601,6 +4601,22 @@ void func_800F5ACC(u16 seqId) {
}
}
// based on func_800F5ACC
void PreviewSequence(u16 seqId) {
u16 curSeqId = func_800FA0B4(SEQ_PLAYER_BGM_MAIN);
if ((curSeqId & 0xFF) != NA_BGM_GANON_TOWER && (curSeqId & 0xFF) != NA_BGM_ESCAPE && curSeqId != seqId) {
Audio_SetSequenceMode(SEQ_MODE_IGNORE);
if (curSeqId != NA_BGM_DISABLED) {
sPrevMainBgmSeqId = curSeqId;
} else {
osSyncPrintf("Middle Boss BGM Start not stack \n");
}
Audio_QueuePreviewSeqCmd(seqId);
}
}
/**
* Restores the previous sequence to the main bgm player before func_800F5ACC was called
*/

View file

@ -221,7 +221,7 @@ void Audio_ProcessSoundRequest(void)
if (req->sfxId == 0) {
return;
}
u16 newSfxId = SfxEditor_GetReplacementSeq(req->sfxId);
u16 newSfxId = AudioEditor_GetReplacementSeq(req->sfxId);
if (req->sfxId != newSfxId) {
gAudioContext.seqReplaced[SEQ_PLAYER_SFX] = 1;
req->sfxId = newSfxId;

View file

@ -373,7 +373,7 @@ void Audio_QueueSeqCmd(u32 cmd)
if (op == 0 || op == 2 || op == 12) {
u8 seqId = cmd & 0xFF;
u8 playerIdx = GET_PLAYER_IDX(cmd);
u16 newSeqId = SfxEditor_GetReplacementSeq(seqId);
u16 newSeqId = AudioEditor_GetReplacementSeq(seqId);
gAudioContext.seqReplaced[playerIdx] = (seqId != newSeqId);
gAudioContext.seqToPlay[playerIdx] = newSeqId;
cmd |= (seqId & 0xFF);
@ -382,6 +382,12 @@ void Audio_QueueSeqCmd(u32 cmd)
sAudioSeqCmds[sSeqCmdWrPos++] = cmd;
}
void Audio_QueuePreviewSeqCmd(u16 seqId) {
gAudioContext.seqReplaced[0] = 1;
gAudioContext.seqToPlay[0] = seqId;
sAudioSeqCmds[sSeqCmdWrPos++] = 1;
}
void Audio_ProcessSeqCmds(void) {
while (sSeqCmdWrPos != sSeqCmdRdPos) {
Audio_ProcessSeqCmd(sAudioSeqCmds[sSeqCmdRdPos++]);