diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2022-06-14 00:59:31 -0400 |
|---|---|---|
| committer | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2022-06-15 15:57:52 -0400 |
| commit | 416173fa79b77ddbdb6a9870528db10bfa4cd21a (patch) | |
| tree | 3e31f54abd3119fd4e96b2deb8e8ce3d3ff73be0 /soh | |
| parent | 99e3d9a8992fa722ddf1af6ef52b3a01bebba4c7 (diff) | |
Added names for the soundfonts.
Diffstat (limited to 'soh')
| -rw-r--r-- | soh/assets/xml/GC_NMQ_D/audio/Audio.xml | 41 | ||||
| -rw-r--r-- | soh/include/z64audio.h | 2 | ||||
| -rw-r--r-- | soh/soh/OTRGlobals.cpp | 20 | ||||
| -rw-r--r-- | soh/soh/OTRGlobals.h | 3 | ||||
| -rw-r--r-- | soh/src/code/audio_init_params.c | 3 | ||||
| -rw-r--r-- | soh/src/code/audio_load.c | 35 | ||||
| -rw-r--r-- | soh/src/code/audio_playback.c | 6 |
7 files changed, 77 insertions, 33 deletions
diff --git a/soh/assets/xml/GC_NMQ_D/audio/Audio.xml b/soh/assets/xml/GC_NMQ_D/audio/Audio.xml index 2d35b24c2..e021bb0ac 100644 --- a/soh/assets/xml/GC_NMQ_D/audio/Audio.xml +++ b/soh/assets/xml/GC_NMQ_D/audio/Audio.xml @@ -1171,7 +1171,7 @@ </Sample> </Samples> <Samples Bank="1"> - <Sample Name="Ocarina"> + <Sample Name="Ocarina_Bank1"> <Offset Version="MQDebug" At="0xFAD40"/> </Sample> <Sample Name="Accordion"> @@ -1514,6 +1514,45 @@ </Sample> </Samples> + + <Soundfont Name="02_Ambient_Sounds" Index="2"/> + <Soundfont Name="37_Unused_Deku_Tree" Index="37" OverrideSampleBank="2"/> + <Soundfont Name="04_Deku_Tree" Index="4"/> + <Soundfont Name="11_Dodongos_Cavern" Index="11"/> + <Soundfont Name="33_Ending_1" Index="33"/> + <Soundfont Name="34_Ending_2" Index="34"/> + <Soundfont Name="09_Fairy_Fountain" Index="9"/> + <Soundfont Name="10_Fire_Temple" Index="10"/> + <Soundfont Name="12_Forest_Temple" Index="12"/> + <Soundfont Name="35_Game_Over" Index="35"/> + <Soundfont Name="30_Ganons_Castle_Organ" Index="30"/> + <Soundfont Name="31_Ganons_Castle" Index="31"/> + <Soundfont Name="32_Ganondorfs_Battle" Index="32"/> + <Soundfont Name="27_Gerudo_Valley" Index="27"/> + <Soundfont Name="14_Goron_City" Index="14"/> + <Soundfont Name="17_Horse_Race" Index="17"/> + <Soundfont Name="23_Ice_Cavern" Index="23"/> + <Soundfont Name="07_Jabu_Jabu" Index="7"/> + <Soundfont Name="36_Kaepora_Gaeboras_Theme" Index="36"/> + <Soundfont Name="08_Child_Kakariko_Village" Index="8"/> + <Soundfont Name="15_Kokiri_Forest" Index="15"/> + <Soundfont Name="29_Kotake_and_Koumes_Theme" Index="29"/> + <Soundfont Name="28_Lakeside_Laboratory" Index="28"/> + <Soundfont Name="19_Legends_of_Hyrule" Index="19"/> + <Soundfont Name="13_Lon_Lon_Ranch" Index="13"/> + <Soundfont Name="05_Market" Index="5"/> + <Soundfont Name="20_Minigames" Index="20"/> + <Soundfont Name="03_Orchestra" Index="3"/> + <Soundfont Name="24_Shadow_Temple" Index="24"/> + <Soundfont Name="22_Shops" Index="22"/> + <Soundfont Name="00_Sound_Effects_1" Index="0" Symbol="gSoundEffectsFont1"/> + <Soundfont Name="01_Sound_Effects_2" Index="1" Symbol="gSoundEffectsFont2"/> + <Soundfont Name="16_Spirit_Temple" Index="16"/> + <Soundfont Name="06_Title_Theme" Index="6"/> + <Soundfont Name="26_Unused" Index="26"/> + <Soundfont Name="18_Warp_Songs" Index="18"/> + <Soundfont Name="25_Water_Temple" Index="25"/> + <Soundfont Name="21_Zoras_Domain" Index="21"/> </Audio> diff --git a/soh/include/z64audio.h b/soh/include/z64audio.h index b804eb193..2eb497571 100644 --- a/soh/include/z64audio.h +++ b/soh/include/z64audio.h @@ -21,6 +21,7 @@ #define CALC_RESAMPLE_FREQ(sampleRate) ((float)sampleRate / (s32)gAudioContext.audioBufferParameters.frequency) extern bool gUseLegacySD; +extern char* fontMap[256]; typedef enum { /* 0 */ ADSR_STATE_DISABLED, @@ -233,6 +234,7 @@ typedef struct { /* 0x08 */ Instrument** instruments; /* 0x0C */ Drum** drums; /* 0x10 */ SoundFontSound* soundEffects; + s32 fntIndex; } SoundFont; // size = 0x14 typedef struct { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a9332573a..125207a5b 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -567,18 +567,6 @@ extern "C" Vtx* ResourceMgr_LoadVtxByName(const char* path) return (Vtx*)res->vertices.data(); } -extern "C" SequenceData ResourceMgr_LoadSeqByID(int seqID) { - if (seqID == 0xFF) { - SequenceData sDat; - sDat.numFonts = 0; - - return sDat; - } - - std::string fmtStr = "audio/sequences/seq_%02X"; - return ResourceMgr_LoadSeqByName(StringHelper::Sprintf(fmtStr.c_str(), seqID).c_str()); -} - extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) { auto file = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(path).get(); @@ -604,8 +592,6 @@ std::map<std::string, SoundFontSample*> cachedCustomSFs; extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) { - //auto str = StringHelper::Sprintf("audio/samples/sample_%08X", romOffset); - if (std::string(path) == "") return nullptr; @@ -694,10 +680,9 @@ extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) } } -extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(int fontIndex) { +extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) { auto soundFont = - std::static_pointer_cast<Ship::AudioSoundFont>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource( - StringHelper::Sprintf("audio/fonts/font_%02X", fontIndex))); + std::static_pointer_cast<Ship::AudioSoundFont>(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); if (soundFont == nullptr) return NULL; @@ -710,6 +695,7 @@ extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(int fontIndex) { { SoundFont* soundFontC = (SoundFont*)malloc(sizeof(SoundFont)); + soundFontC->fntIndex = soundFont->id; soundFontC->numDrums = soundFont->drums.size(); soundFontC->numInstruments = soundFont->instruments.size(); soundFontC->numSfx = soundFont->soundEffects.size(); diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index f5b3e25d3..851a3cfaf 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -47,8 +47,7 @@ Gfx* ResourceMgr_LoadGfxByName(const char* path); Gfx* ResourceMgr_PatchGfxByName(const char* path, int size); Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc); Vtx* ResourceMgr_LoadVtxByName(const char* path); -SoundFont* ResourceMgr_LoadAudioSoundFont(int fontIndex); -SequenceData ResourceMgr_LoadSeqByID(int seqID); +SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path); SequenceData ResourceMgr_LoadSeqByName(const char* path); SoundFontSample* ResourceMgr_LoadAudioSample(const char* path); CollisionHeader* ResourceMgr_LoadColByName(const char* path); diff --git a/soh/src/code/audio_init_params.c b/soh/src/code/audio_init_params.c index ebe5e8130..95af11421 100644 --- a/soh/src/code/audio_init_params.c +++ b/soh/src/code/audio_init_params.c @@ -10,7 +10,8 @@ const s16 D_8014A6C0[] = { 0x0030, // gTatumsPerBeat }; -const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 }; +//const AudioContextInitSizes D_8014A6C4 = { 0x37F00, 0xE0E0, 0xBCE0 }; +const AudioContextInitSizes D_8014A6C4 = { 0x37F000, 0xE0E00, 0xBCE00 }; // OTRTODO: This might be overkill... ReverbSettings D_80133420[][3] = { { diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c index 3056a442b..29226bcbe 100644 --- a/soh/src/code/audio_load.c +++ b/soh/src/code/audio_load.c @@ -76,6 +76,7 @@ void* sUnusedHandler = NULL; s32 gAudioContextInitalized = false; char* sequenceMap[256]; +char* fontMap[256]; uintptr_t fontStart; uint32_t fontOffsets[8192]; @@ -690,7 +691,8 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { } if (!gUseLegacySD) { - SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId); + SoundFont* sf = ResourceMgr_LoadAudioSoundFont + (fontMap[fontId]); sampleBankId1 = sf->sampleBankId1; sampleBankId2 = sf->sampleBankId2; @@ -757,7 +759,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) { } else if (!gUseLegacySD && tableType == FONT_TABLE) { - fnt = ResourceMgr_LoadAudioSoundFont(id); + fnt = ResourceMgr_LoadAudioSoundFont(fontMap[id]); size = sizeof(SoundFont); medium = 2; cachePolicy = 0; @@ -895,7 +897,7 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo Drum* drum; SoundFontSound* sfx; s32 i; - SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId); + SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]); s32 numDrums = 0; s32 numInstruments = 0; @@ -1433,10 +1435,6 @@ void AudioLoad_Init(void* heap, u32 heapSize) { if (gUseLegacySD) numFonts = gAudioContext.soundFontTable->numEntries; - else - numFonts = 0x26; // OTRTODO: Count the number of soundfonts that are inside the OTR(s) - - gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); if (gUseLegacySD) { for (i = 0; i < numFonts; i++) { @@ -1460,9 +1458,28 @@ void AudioLoad_Init(void* heap, u32 heapSize) { free(seqList); + int fntListSize = 0; + char** fntList = ResourceMgr_ListFiles("audio/fonts*", &fntListSize); + + for (int i = 0; i < fntListSize; i++) + { + SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fntList[i]); + + char* str = malloc(strlen(fntList[i]) + 1); + strcpy(str, fntList[i]); + + fontMap[sf->fntIndex] = str; + } + + numFonts = fntListSize; + + free(fntList); + int bp = 0; } + gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + if (temp_v0_3 = AudioHeap_Alloc(&gAudioContext.audioInitPool, D_8014A6C4.permanentPoolSize), temp_v0_3 == NULL) { // cast away const from D_8014A6C4 *((u32*)&D_8014A6C4.permanentPoolSize) = 0; @@ -2182,7 +2199,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, RelocInfo* relocInfo gAudioContext.numUsedSamples = 0; if (!gUseLegacySD) { - SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId); + SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]); numDrums = sf->numDrums; numInstruments = sf->numInstruments; @@ -2319,7 +2336,7 @@ void AudioLoad_LoadPermanentSamples(void) { //fontId = gAudioContext.permanentCache[i].id; if (!gUseLegacySD) { - SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId); + SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]); relocInfo.sampleBankId1 = sf->sampleBankId1; relocInfo.sampleBankId2 = sf->sampleBankId2; } else { diff --git a/soh/src/code/audio_playback.c b/soh/src/code/audio_playback.c index 9992eee3d..df64e2c7b 100644 --- a/soh/src/code/audio_playback.c +++ b/soh/src/code/audio_playback.c @@ -342,7 +342,7 @@ Instrument* Audio_GetInstrumentInner(s32 fontId, s32 instId) { return NULL; } } else { - SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId); + SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]); if (instId >= sf->numInstruments) return NULL; @@ -379,7 +379,7 @@ Drum* Audio_GetDrum(s32 fontId, s32 drumId) { drum = gAudioContext.soundFonts[fontId].drums[drumId]; } else { - SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId); + SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]); drum = sf->drums[drumId]; } @@ -410,7 +410,7 @@ SoundFontSound* Audio_GetSfx(s32 fontId, s32 sfxId) { sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId]; } else { - SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontId); + SoundFont* sf = ResourceMgr_LoadAudioSoundFont(fontMap[fontId]); sfx = &sf->soundEffects[sfxId]; } |
