Skip to content

Commit

Permalink
Added Binary extraction for AudioTables
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritoDv committed Nov 20, 2024
1 parent 0ece28f commit 2e915fe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/factories/ResourceType.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ enum class ResourceType {
AdpcmLoop = 0x4150434C, // APCL
AdpcmBook = 0x41504342, // APCB
Envelope = 0x45564C50, // EVLP
AudioTable = 0x4154424C
};
} // namespace LUS
27 changes: 22 additions & 5 deletions src/factories/naudio/v1/AudioTableFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,29 @@ ExportResult AudioTableCodeExporter::Export(std::ostream &write, std::shared_ptr

ExportResult AudioTableBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
auto writer = LUS::BinaryWriter();
// auto data = std::static_pointer_cast<AudioTableEntry>(raw)->mBuffer;
auto data = std::static_pointer_cast<AudioTableData>(raw);

// WriteHeader(writer, Torch::ResourceType::Blob, 0);
// writer.Write((uint32_t) data.size());
// writer.Write((char*) data.data(), data.size());
// writer.Finish(write);
WriteHeader(writer, Torch::ResourceType::AudioTable, 0);
writer.Write((uint8_t) data->type);
writer.Write(data->medium);
writer.Write(data->addr);
writer.Write((uint32_t) data->entries.size());

for(auto& entry : data->entries){
if(data->type != AudioTableType::SAMPLE_TABLE){
writer.Write(AudioContext::GetPathByAddr(entry.addr));
} else {
writer.Write((uint64_t) entry.addr);
}
writer.Write(entry.size);
writer.Write(entry.medium);
writer.Write(entry.cachePolicy);
writer.Write(entry.shortData1);
writer.Write(entry.shortData2);
writer.Write(entry.shortData3);
}

writer.Finish(write);
return std::nullopt;
}

Expand Down

0 comments on commit 2e915fe

Please sign in to comment.