From 27af72331ceba7703f0382bb0316320baed377a3 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Mon, 3 Feb 2025 03:11:46 -0600 Subject: [PATCH] Fixed xml sample extraction --- src/factories/naudio/v1/SampleFactory.cpp | 7 ++----- src/factories/naudio/v1/SoundFontFactory.cpp | 18 ++++++++---------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/factories/naudio/v1/SampleFactory.cpp b/src/factories/naudio/v1/SampleFactory.cpp index 3a40883..616d883 100644 --- a/src/factories/naudio/v1/SampleFactory.cpp +++ b/src/factories/naudio/v1/SampleFactory.cpp @@ -82,9 +82,6 @@ ExportResult NSampleXMLExporter::Export(std::ostream &write, std::shared_ptr(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_ptrSetAttribute("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(Companion::Instance->GetParseDataByAddr(entry->loop)->data.value()); @@ -134,7 +131,7 @@ ExportResult NSampleXMLExporter::Export(std::ostream &write, std::shared_ptrentries[entry->sampleBankId].addr + entry->sampleAddr; std::vector data(sampleData, sampleData + entry->size); - Companion::Instance->RegisterCompanionFile(path.filename().string(), data); + Companion::Instance->RegisterCompanionFile(path.filename().string() + "_data", data); return std::nullopt; } diff --git a/src/factories/naudio/v1/SoundFontFactory.cpp b/src/factories/naudio/v1/SoundFontFactory.cpp index e0ba51c..cd00123 100644 --- a/src/factories/naudio/v1/SoundFontFactory.cpp +++ b/src/factories/naudio/v1/SoundFontFactory.cpp @@ -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(Companion::Instance->GetNodeByAddr(lowSample.sample).value()).c_str()); + low->SetAttribute("SampleRef", (std::get(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(Companion::Instance->GetNodeByAddr(normSample.sample).value()).c_str()); + normal->SetAttribute("SampleRef", (std::get(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(Companion::Instance->GetNodeByAddr(highSample.sample).value()).c_str()); + high->SetAttribute("SampleRef", (std::get(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(Companion::Instance->GetNodeByAddr(sample.sample).value()).c_str()); + root->SetAttribute("SampleRef", (std::get(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(node, "sd2"); auto sd3 = (int16_t) GetSafeNode(node, "sd3"); - *replacement += ".meta"; - tinyxml2::XMLDocument doc; tinyxml2::XMLElement* root = doc.NewElement("SoundFont"); root->SetAttribute("Version", 0);