mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-22 16:18:50 -05:00
Added names for the soundfonts.
This commit is contained in:
parent
99e3d9a899
commit
416173fa79
@ -161,7 +161,8 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
|
||||
WriteSoundFontEntry(audio, audio->soundFontTable[i].soundEffects[k], audio->samples, &fntWriter);
|
||||
}
|
||||
|
||||
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, StringHelper::Sprintf("fonts/font_%02X", i));
|
||||
//std::string fName = OTRExporter_DisplayList::GetPathToRes(res, StringHelper::Sprintf("fonts/font_%02X", i));
|
||||
std::string fName = OTRExporter_DisplayList::GetPathToRes(res, StringHelper::Sprintf("fonts/%s", audio->soundFontNames[i].c_str()));
|
||||
AddFile(fName, fntStream->ToVector());
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,13 @@ void ZAudio::ParseXML(tinyxml2::XMLElement* reader)
|
||||
}
|
||||
}
|
||||
|
||||
if (std::string(child->Value()) == "Soundfont")
|
||||
{
|
||||
auto name = child->Attribute("Name");
|
||||
auto index = child->IntAttribute("Index", 0);
|
||||
soundFontNames[index] = name;
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
@ -154,14 +161,10 @@ SampleEntry* ZAudio::ParseSampleEntry(std::vector<uint8_t> audioBank,
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
if (/* sample->loop.count != 0xFFFFFFFF && */ sample->loop.count != 0)
|
||||
if (sample->loop.count != 0)
|
||||
{
|
||||
//for (int i = 0; i < sample->loop.count; i++)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
//if ((loopOffset + 16 + (i * 2)) >= audioBank.size())
|
||||
//break;
|
||||
|
||||
int16_t state = BitConverter::ToInt16BE(audioBank, loopOffset + 16 + (i * 2));
|
||||
sample->loop.states.push_back(state);
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ public:
|
||||
std::map<uint32_t, SampleEntry*> samples;
|
||||
std::vector<std::vector<uint32_t>> fontIndices;
|
||||
std::vector<std::string> seqNames;
|
||||
std::map<uint32_t, std::string> soundFontNames;
|
||||
|
||||
// First Key = Bank ID, Sec Key = LoopDataOffset, Third Key = Sample Data Offset
|
||||
std::map<uint32_t, std::map<uint32_t, std::map<uint32_t, std::string>>> sampleOffsets;
|
||||
|
@ -2085,7 +2085,7 @@ static inline void* seg_addr(uintptr_t w1)
|
||||
uint32_t segNum = (w1 >> 24);
|
||||
|
||||
uint32_t offset = w1 & 0x00FFFFFE;
|
||||
offset = 0; // Cursed Malon bug
|
||||
//offset = 0; // Cursed Malon bug
|
||||
|
||||
if (segmentPointers[segNum] != 0)
|
||||
return (void*)(segmentPointers[segNum] + offset);
|
||||
|
@ -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">
|
||||
@ -1515,6 +1515,45 @@
|
||||
</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>
|
||||
</File>
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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] = {
|
||||
{
|
||||
|
@ -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 {
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user