From 4459958deed7af3c9ed7343914789709d6ef6ef1 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sat, 4 Jan 2025 21:03:51 -0600 Subject: [PATCH] Removed duplicated XML factory --- src/factories/naudio/v1/InstrumentFactory.cpp | 63 +------------------ src/factories/naudio/v1/InstrumentFactory.h | 4 -- 2 files changed, 1 insertion(+), 66 deletions(-) diff --git a/src/factories/naudio/v1/InstrumentFactory.cpp b/src/factories/naudio/v1/InstrumentFactory.cpp index 10ba852..19989db 100644 --- a/src/factories/naudio/v1/InstrumentFactory.cpp +++ b/src/factories/naudio/v1/InstrumentFactory.cpp @@ -42,67 +42,6 @@ ExportResult InstrumentBinaryExporter::Export(std::ostream &write, std::shared_p return std::nullopt; } -ExportResult InstrumentXMLExporter::Export(std::ostream &write, std::shared_ptr raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { - auto writer = LUS::BinaryWriter(); - auto instrument = std::static_pointer_cast(raw); - - auto envelopeData = std::static_pointer_cast(Companion::Instance->GetParseDataByAddr(instrument->envelope)->data.value()); - - auto path = fs::path(*replacement); - - *replacement += ".meta"; - - tinyxml2::XMLDocument inst; - tinyxml2::XMLElement* root = inst.NewElement("Instrument"); - root->SetAttribute("NormalRangeLo", instrument->normalRangeLo); - root->SetAttribute("NormalRangeHi", instrument->normalRangeLo); - root->SetAttribute("ReleaseRate", instrument->adsrDecayIndex); - - tinyxml2::XMLElement* envelopes = inst.NewElement("Envelopes"); - for(auto& point : envelopeData->points){ - tinyxml2::XMLElement* pointEntry = envelopes->InsertNewChildElement("Point"); - pointEntry->SetAttribute("Delay", point.delay); - pointEntry->SetAttribute("Arg", point.arg); - envelopes->InsertEndChild(pointEntry); - } - - auto lowSample = instrument->lowPitchTunedSample; - auto normSample = instrument->normalPitchTunedSample; - auto highSample = instrument->highPitchTunedSample; - - if(lowSample.sample != 0 && lowSample.tuning != 0.0f){ - tinyxml2::XMLElement* low = inst.NewElement("LowPitchSample"); - low->SetAttribute("Tuning", lowSample.tuning); - low->SetAttribute("Path", std::get(Companion::Instance->GetNodeByAddr(lowSample.sample).value()).c_str()); - - root->InsertEndChild(low); - } - - if(normSample.sample != 0 && normSample.tuning != 0.0f) { - tinyxml2::XMLElement* normal = inst.NewElement("NormalPitchSample"); - normal->SetAttribute("Tuning", normSample.tuning); - normal->SetAttribute("Path", std::get(Companion::Instance->GetNodeByAddr(normSample.sample).value()).c_str()); - - root->InsertEndChild(normal); - } - - if(highSample.sample != 0 && highSample.tuning != 0.0f) { - tinyxml2::XMLElement* high = inst.NewElement("HighPitchSample"); - high->SetAttribute("Tuning", highSample.tuning); - high->SetAttribute("Path", std::get(Companion::Instance->GetNodeByAddr(highSample.sample).value()).c_str()); - - root->InsertEndChild(high); - } - - inst.InsertEndChild(root); - - tinyxml2::XMLPrinter printer; - inst.Accept(&printer); - write.write(printer.CStr(), printer.CStrSize() - 1); - - return std::nullopt; -} - std::optional> InstrumentFactory::parse(std::vector& buffer, YAML::Node& node) { auto offset = GetSafeNode(node, "offset"); auto parent = GetSafeNode(node, "parent"); @@ -124,7 +63,7 @@ std::optional> InstrumentFactory::parse(std::vector envelope["offset"] = envAddr; instrument->envelope = envAddr; Companion::Instance->AddAsset(envelope); - + instrument->lowPitchTunedSample = AudioContext::LoadTunedSample(reader, parent, sampleBankId); instrument->normalPitchTunedSample = AudioContext::LoadTunedSample(reader, parent, sampleBankId); instrument->highPitchTunedSample = AudioContext::LoadTunedSample(reader, parent, sampleBankId); diff --git a/src/factories/naudio/v1/InstrumentFactory.h b/src/factories/naudio/v1/InstrumentFactory.h index 245b6d9..9af9295 100644 --- a/src/factories/naudio/v1/InstrumentFactory.h +++ b/src/factories/naudio/v1/InstrumentFactory.h @@ -27,10 +27,6 @@ class InstrumentCodeExporter : public BaseExporter { ExportResult Export(std::ostream& write, std::shared_ptr data, std::string& entryName, YAML::Node& node, std::string* replacement) override; }; -class InstrumentXMLExporter : public BaseExporter { - ExportResult Export(std::ostream& write, std::shared_ptr data, std::string& entryName, YAML::Node& node, std::string* replacement) override; -}; - class InstrumentFactory : public BaseFactory { public: std::optional> parse(std::vector& buffer, YAML::Node& data) override;