Fixed xml sample extraction

This commit is contained in:
KiritoDv
2025-02-03 03:11:46 -06:00
parent 2ab2ec2326
commit 27af72331c
2 changed files with 10 additions and 15 deletions
+2 -5
View File
@@ -82,9 +82,6 @@ ExportResult NSampleXMLExporter::Export(std::ostream &write, std::shared_ptr<IPa
auto entry = std::static_pointer_cast<NSampleData>(raw);
auto path = fs::path(*replacement);
*replacement += ".meta";
tinyxml2::XMLDocument sample;
tinyxml2::XMLElement* root = sample.NewElement("Sample");
root->SetAttribute("Version", 0);
@@ -94,7 +91,7 @@ ExportResult NSampleXMLExporter::Export(std::ostream &write, std::shared_ptr<IPa
root->SetAttribute("Tuning", entry->tuning);
root->SetAttribute("Size", entry->size);
root->SetAttribute("Relocated", 0);
root->SetAttribute("Path", path.c_str());
root->SetAttribute("Path", (path.string() + "_data").c_str());
if(entry->loop != 0) {
auto loop = std::static_pointer_cast<ADPCMLoopData>(Companion::Instance->GetParseDataByAddr(entry->loop)->data.value());
@@ -134,7 +131,7 @@ ExportResult NSampleXMLExporter::Export(std::ostream &write, std::shared_ptr<IPa
auto table = AudioContext::tables[AudioTableType::SAMPLE_TABLE];
auto sampleData = table.buffer.data() + table.info->entries[entry->sampleBankId].addr + entry->sampleAddr;
std::vector<char> data(sampleData, sampleData + entry->size);
Companion::Instance->RegisterCompanionFile(path.filename().string(), data);
Companion::Instance->RegisterCompanionFile(path.filename().string() + "_data", data);
return std::nullopt;
}
+8 -10
View File
@@ -55,7 +55,7 @@ void WriteInstrument(tinyxml2::XMLElement* parent, uint32_t offset){
tinyxml2::XMLElement* root = parent->InsertNewChildElement("Instrument");
root->SetAttribute("NormalRangeLo", instrument->normalRangeLo);
root->SetAttribute("NormalRangeHi", instrument->normalRangeLo);
root->SetAttribute("NormalRangeHi", instrument->normalRangeHi);
root->SetAttribute("ReleaseRate", instrument->adsrDecayIndex);
tinyxml2::XMLElement* envelopes = root->InsertNewChildElement("Envelopes");
@@ -72,25 +72,25 @@ void WriteInstrument(tinyxml2::XMLElement* parent, uint32_t offset){
auto highSample = instrument->highPitchTunedSample;
if(lowSample.sample != 0 && lowSample.tuning != 0.0f){
tinyxml2::XMLElement* low = root->InsertNewChildElement("LowPitchSample");
tinyxml2::XMLElement* low = root->InsertNewChildElement("LowNotesSound");
low->SetAttribute("Tuning", lowSample.tuning);
low->SetAttribute("SampleRef", std::get<std::string>(Companion::Instance->GetNodeByAddr(lowSample.sample).value()).c_str());
low->SetAttribute("SampleRef", (std::get<std::string>(Companion::Instance->GetNodeByAddr(lowSample.sample).value())).c_str());
root->InsertEndChild(low);
}
if(normSample.sample != 0 && normSample.tuning != 0.0f) {
tinyxml2::XMLElement* normal = root->InsertNewChildElement("NormalPitchSample");
tinyxml2::XMLElement* normal = root->InsertNewChildElement("NormalNotesSound");
normal->SetAttribute("Tuning", normSample.tuning);
normal->SetAttribute("SampleRef", std::get<std::string>(Companion::Instance->GetNodeByAddr(normSample.sample).value()).c_str());
normal->SetAttribute("SampleRef", (std::get<std::string>(Companion::Instance->GetNodeByAddr(normSample.sample).value())).c_str());
root->InsertEndChild(normal);
}
if(highSample.sample != 0 && highSample.tuning != 0.0f) {
tinyxml2::XMLElement* high = root->InsertNewChildElement("HighPitchSample");
tinyxml2::XMLElement* high = root->InsertNewChildElement("HighNotesSound");
high->SetAttribute("Tuning", highSample.tuning);
high->SetAttribute("SampleRef", std::get<std::string>(Companion::Instance->GetNodeByAddr(highSample.sample).value()).c_str());
high->SetAttribute("SampleRef", (std::get<std::string>(Companion::Instance->GetNodeByAddr(highSample.sample).value())).c_str());
root->InsertEndChild(high);
}
@@ -107,7 +107,7 @@ void WriteDrum(tinyxml2::XMLElement* parent, uint32_t offset){
root->SetAttribute("ReleaseRate", drum->adsrDecayIndex);
root->SetAttribute("Pan", drum->pan);
root->SetAttribute("Loaded", 0);
root->SetAttribute("SampleRef", std::get<std::string>(Companion::Instance->GetNodeByAddr(sample.sample).value()).c_str());
root->SetAttribute("SampleRef", (std::get<std::string>(Companion::Instance->GetNodeByAddr(sample.sample).value())).c_str());
root->SetAttribute("Tuning", sample.tuning);
tinyxml2::XMLElement* envelopes = root->InsertNewChildElement("Envelopes");
@@ -132,8 +132,6 @@ ExportResult SoundFontXMLExporter::Export(std::ostream &write, std::shared_ptr<I
auto sd2 = (int16_t) GetSafeNode<int32_t>(node, "sd2");
auto sd3 = (int16_t) GetSafeNode<int32_t>(node, "sd3");
*replacement += ".meta";
tinyxml2::XMLDocument doc;
tinyxml2::XMLElement* root = doc.NewElement("SoundFont");
root->SetAttribute("Version", 0);