From cb896a4fa1acd9167d3e7ee9f6336a63309eebde Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 24 May 2018 20:44:33 +0200 Subject: Add save/load of selections/regions in instruments. --- src/projectserialiser.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'src/projectserialiser.cc') diff --git a/src/projectserialiser.cc b/src/projectserialiser.cc index 44f9ff7..f70e6dd 100644 --- a/src/projectserialiser.cc +++ b/src/projectserialiser.cc @@ -128,6 +128,15 @@ QString ProjectSerialiser::serialise(const Project& project) for(const auto& i : project.instruments) { auto instrument = doc.createElement("instrument"); + + instrument.setAttribute("attack_length", (int)i.getAttackLength()); + instrument.setAttribute("power_spread", (int)i.getPowerSpread()); + instrument.setAttribute("minimum_size", (int)i.getMinimumSize()); + instrument.setAttribute("falloff", (int)i.getFalloff()); + instrument.setAttribute("fade_length", (int)i.getFadeLength()); + + instrument.setAttribute("threshold", i.getThreshold()); + instruments.appendChild(instrument); auto instrument_name = doc.createElement("instrument_name"); @@ -145,6 +154,24 @@ QString ProjectSerialiser::serialise(const Project& project) file.setAttribute("master", i.master_file == f.first); file_list.appendChild(file); } + + auto regions = doc.createElement("regions"); + regions.setAttribute("nextid", i.selections.nextid); + regions.setAttribute("act", i.selections.act); + instrument.appendChild(regions); + + for(auto r = i.selections.sels.begin(); r != i.selections.sels.end(); ++r) + { + auto region = doc.createElement("region"); + region.setAttribute("id", (int)r.key()); + region.setAttribute("from", (int)r.value().from); + region.setAttribute("to", (int)r.value().to); + region.setAttribute("fadein", (int)r.value().fadein); + region.setAttribute("fadeout", (int)r.value().fadeout); + region.setAttribute("energy", r.value().energy); + region.setAttribute("name", r.value().name); + regions.appendChild(region); + } } return doc.toString(); @@ -192,8 +219,33 @@ bool ProjectSerialiser::deserialise(const QString& data, Project& project) } file_list.push_back(qMakePair(file.text(), file["name"])); } - project.instruments.back().file_list = file_list; - project.instruments.back().master_file = master_file; + + instr.file_list = file_list; + instr.master_file = master_file; + + instr.attack_length = instrument["attack_length"].toInt(); + instr.power_spread = instrument["power_spread"].toInt();; + instr.minimum_size = instrument["minimum_size"].toInt(); + instr.falloff = instrument["falloff"].toInt(); + instr.fade_length = instrument["fade_length"].toInt(); + + instr.threshold = instrument["threshold"].toFloat(); + + auto selections = instrument("regions"); + instr.selections.nextid = selections["nextid"].toInt(); + instr.selections.act = selections["act"].toInt(); + + for(auto& selection : selections.children()) + { + Selection s; + s.from = selection["from"].toInt(); + s.to = selection["to"].toInt(); + s.fadein = selection["fadein"].toInt(); + s.fadeout = selection["fadeout"].toInt(); + s.energy = selection["energy"].toFloat(); + s.name = selection["name"]; + instr.selections.sels[selection["id"].toInt()] = s; + } } return true; -- cgit v1.2.3