mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-14 10:37:17 -07:00
Fixed last remaining audio bugs
This commit is contained in:
parent
405e6019d2
commit
36eb47e631
9 changed files with 61 additions and 33 deletions
|
@ -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)
|
||||
{
|
||||
//for (int i = 0; i < sample->loop.count; i++)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
int16_t state = BitConverter::ToInt16BE(sample->data, loopOffset + 16 + (i * 2));
|
||||
//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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue