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/src/code | |
| parent | 99e3d9a8992fa722ddf1af6ef52b3a01bebba4c7 (diff) | |
Added names for the soundfonts.
Diffstat (limited to 'soh/src/code')
| -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 |
3 files changed, 31 insertions, 13 deletions
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]; } |
