mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-10-31 15:45:06 -04:00
Fixed last remaining audio bugs
This commit is contained in:
parent
6c94c8690e
commit
0a629ea6e9
@ -10,22 +10,16 @@ void OTRExporter_Audio::WriteSampleEntryReference(ZAudio* audio, SampleEntry* en
|
||||
{
|
||||
writer->Write((uint8_t)(entry != nullptr ? 1 : 0));
|
||||
|
||||
uint32_t addr = 0;
|
||||
|
||||
for (auto pair : samples)
|
||||
{
|
||||
if (pair.second == entry)
|
||||
{
|
||||
addr = pair.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry != nullptr)
|
||||
{
|
||||
if (audio->sampleOffsets[entry->bankId].find(entry->sampleDataOffset) != audio->sampleOffsets[entry->bankId].end())
|
||||
if (audio->sampleOffsets[entry->bankId].find(entry->sampleLoopOffset) != audio->sampleOffsets[entry->bankId].end())
|
||||
{
|
||||
writer->Write(StringHelper::Sprintf("audio/samples/%s", audio->sampleOffsets[entry->bankId][entry->sampleDataOffset].c_str()));
|
||||
if (audio->sampleOffsets[entry->bankId][entry->sampleLoopOffset].find(entry->sampleDataOffset) != audio->sampleOffsets[entry->bankId][entry->sampleLoopOffset].end())
|
||||
{
|
||||
writer->Write(StringHelper::Sprintf("audio/samples/%s", audio->sampleOffsets[entry->bankId][entry->sampleLoopOffset][entry->sampleDataOffset].c_str()));
|
||||
}
|
||||
else
|
||||
writer->Write(entry->fileName);
|
||||
}
|
||||
else
|
||||
writer->Write(entry->fileName);
|
||||
@ -101,8 +95,13 @@ void OTRExporter_Audio::Save(ZResource* res, const fs::path& outPath, BinaryWrit
|
||||
|
||||
std::string basePath = "";
|
||||
|
||||
if (audio->sampleOffsets[pair.second->bankId].find(pair.second->sampleDataOffset) != audio->sampleOffsets[pair.second->bankId].end())
|
||||
basePath = StringHelper::Sprintf("samples/%s", audio->sampleOffsets[pair.second->bankId][pair.second->sampleDataOffset].c_str());
|
||||
if (audio->sampleOffsets[pair.second->bankId].find(pair.second->sampleLoopOffset) != audio->sampleOffsets[pair.second->bankId].end())
|
||||
{
|
||||
if (audio->sampleOffsets[pair.second->bankId][pair.second->sampleLoopOffset].find(pair.second->sampleDataOffset) != audio->sampleOffsets[pair.second->bankId][pair.second->sampleLoopOffset].end())
|
||||
basePath = StringHelper::Sprintf("samples/%s", audio->sampleOffsets[pair.second->bankId][pair.second->sampleLoopOffset][pair.second->sampleDataOffset].c_str());
|
||||
else
|
||||
basePath = StringHelper::Sprintf("samples/sample_%08X", pair.first);
|
||||
}
|
||||
else
|
||||
basePath = StringHelper::Sprintf("samples/sample_%08X", pair.first);
|
||||
|
||||
|
@ -26,7 +26,6 @@ void ZAudio::ParseXML(tinyxml2::XMLElement* reader)
|
||||
|
||||
while (child != nullptr)
|
||||
{
|
||||
int bp = 0;
|
||||
if (std::string(child->Value()) == "Sequences")
|
||||
{
|
||||
auto seqChild = child->FirstChildElement();
|
||||
@ -52,7 +51,17 @@ void ZAudio::ParseXML(tinyxml2::XMLElement* reader)
|
||||
if (std::string(sampChild->Value()) == "Sample")
|
||||
{
|
||||
auto atStr = sampChild->FirstChildElement()->Attribute("At");
|
||||
sampleOffsets[bankId][StringHelper::StrToL(atStr, 16)] = sampChild->Attribute("Name");
|
||||
auto loopStr = sampChild->FirstChildElement()->Attribute("LoopOffset");
|
||||
uint32_t loopOffset = 0xFFFFFFFF;
|
||||
uint32_t atOffset = StringHelper::StrToL(atStr, 16);
|
||||
|
||||
if (loopStr != NULL)
|
||||
{
|
||||
loopOffset = StringHelper::StrToL(loopStr, 16);
|
||||
specialLoopSamples[loopOffset] = atOffset;
|
||||
}
|
||||
|
||||
sampleOffsets[bankId][loopOffset][atOffset] = sampChild->Attribute("Name");
|
||||
}
|
||||
|
||||
sampChild = sampChild->NextSiblingElement();
|
||||
@ -140,11 +149,20 @@ SampleEntry* ZAudio::ParseSampleEntry(std::vector<uint8_t> audioBank,
|
||||
sample->loop.end = BitConverter::ToInt32BE(audioBank, loopOffset + 4);
|
||||
sample->loop.count = BitConverter::ToInt32BE(audioBank, loopOffset + 8);
|
||||
|
||||
if (sample->loop.count != 0xFFFFFFFF)
|
||||
if (sample->loop.start == 0x3ADB)
|
||||
{
|
||||
for (int i = 0; i < sample->loop.count; i++)
|
||||
int bp = 0;
|
||||
}
|
||||
|
||||
if (/* sample->loop.count != 0xFFFFFFFF && */ sample->loop.count != 0)
|
||||
{
|
||||
int16_t state = BitConverter::ToInt16BE(sample->data, loopOffset + 16 + (i * 2));
|
||||
//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);
|
||||
}
|
||||
}
|
||||
@ -159,6 +177,10 @@ SampleEntry* ZAudio::ParseSampleEntry(std::vector<uint8_t> audioBank,
|
||||
}
|
||||
|
||||
sample->sampleDataOffset = sampleDataOffset;
|
||||
|
||||
if (specialLoopSamples.find(loopOffset) != specialLoopSamples.end())
|
||||
sample->sampleLoopOffset = loopOffset;
|
||||
|
||||
sample->fileName = StringHelper::Sprintf("audio/samples/sample_%08X", sampleOffset);
|
||||
|
||||
samples[sampleOffset] = sample;
|
||||
|
@ -29,6 +29,7 @@ struct SampleEntry
|
||||
std::string fileName;
|
||||
uint8_t bankId;
|
||||
uint32_t sampleDataOffset;
|
||||
uint32_t sampleLoopOffset = 0xFFFFFFFF;
|
||||
uint8_t codec;
|
||||
uint8_t medium;
|
||||
uint8_t unk_bit26;
|
||||
@ -94,7 +95,12 @@ public:
|
||||
std::map<uint32_t, SampleEntry*> samples;
|
||||
std::vector<std::vector<uint32_t>> fontIndices;
|
||||
std::vector<std::string> seqNames;
|
||||
std::map<uint32_t, std::map<uint32_t, std::string>> sampleOffsets;
|
||||
|
||||
// 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;
|
||||
|
||||
// Key = Loop Offset, Value = Sample Offset
|
||||
std::map<uint32_t, uint32_t> specialLoopSamples;
|
||||
|
||||
ZAudio(ZFile* nParent);
|
||||
|
||||
|
@ -73,11 +73,11 @@ namespace Ship
|
||||
{
|
||||
InstrumentEntry entry;
|
||||
|
||||
entry.isValidEntry = reader->ReadByte();
|
||||
entry.loaded = reader->ReadByte();
|
||||
entry.normalRangeLo = reader->ReadByte();
|
||||
entry.normalRangeHi = reader->ReadByte();
|
||||
entry.releaseRate = reader->ReadByte();
|
||||
entry.isValidEntry = reader->ReadUByte();
|
||||
entry.loaded = reader->ReadUByte();
|
||||
entry.normalRangeLo = reader->ReadUByte();
|
||||
entry.normalRangeHi = reader->ReadUByte();
|
||||
entry.releaseRate = reader->ReadUByte();
|
||||
|
||||
entry.env = ReadEnvelopeData(reader);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -461,8 +461,11 @@
|
||||
<Sample Name="Person Whistling">
|
||||
<Offset Version="MQDebug" At="0xF72A0"/>
|
||||
</Sample>
|
||||
<Sample Name="Ocarina">
|
||||
<Offset Version="MQDebug" At="0xFAD40"/>
|
||||
<Sample Name="Ocarina_Looped">
|
||||
<Offset Version="MQDebug" At="0xFAD40" LoopOffset="0x1550"/>
|
||||
</Sample>
|
||||
<Sample Name="Ocarina_NoLooped">
|
||||
<Offset Version="MQDebug" At="0xFAD40" LoopOffset="0x77C0"/>
|
||||
</Sample>
|
||||
<Sample Name="Accordion">
|
||||
<Offset Version="MQDebug" At="0xFDFC0"/>
|
||||
|
@ -687,7 +687,6 @@ typedef struct {
|
||||
union{
|
||||
u32 opArgs;
|
||||
struct {
|
||||
// OTRTODO: struct members swapped for quick audio
|
||||
u8 arg2;
|
||||
u8 arg1;
|
||||
u8 arg0;
|
||||
|
@ -66,7 +66,6 @@ ReverbSettings D_80133420[][3] = {
|
||||
},
|
||||
};
|
||||
|
||||
// OTRTODO
|
||||
AudioSpec gAudioSpecs[18] = {
|
||||
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[0], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x4000, 0x2880, 0, 0, 0 },
|
||||
{ 44100, 1, 24, 4, 0, 0, 2, D_80133420[1], 0x300, 0x200, 0x7FFF, 0x7F0, 0xE00, 0, 0x3800, 0x2880, 0, 0, 0 },
|
||||
|
@ -561,8 +561,8 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat
|
||||
NoteSubEu* noteSubEu2;
|
||||
s32 unk14;
|
||||
|
||||
if (aiBufLen == 0)
|
||||
return;
|
||||
//if (aiBufLen == 0)
|
||||
//return;
|
||||
|
||||
t = gAudioContext.numNotes * updateIndex;
|
||||
count = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user