summaryrefslogtreecommitdiff
path: root/src/projectserialiser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/projectserialiser.cc')
-rw-r--r--src/projectserialiser.cc69
1 files changed, 52 insertions, 17 deletions
diff --git a/src/projectserialiser.cc b/src/projectserialiser.cc
index f80fa36..ced4636 100644
--- a/src/projectserialiser.cc
+++ b/src/projectserialiser.cc
@@ -122,6 +122,23 @@ QString ProjectSerialiser::serialise(const Project& project)
raw_file_root.appendChild(doc.createTextNode(project.raw_file_root));
dgedit.appendChild(raw_file_root);
+ auto export_path = doc.createElement("export_path");
+ export_path.appendChild(doc.createTextNode(project.export_path));
+ dgedit.appendChild(export_path);
+
+ dgedit.setAttribute("next_id", project.next_id);
+
+ auto channels = doc.createElement("channels");
+ dgedit.appendChild(channels);
+
+ for(const auto& c : project.channels)
+ {
+ auto channel = doc.createElement("channel");
+ channel.setAttribute("id", c.getId());
+ channel.setAttribute("name", c.getChannelName());
+ channels.appendChild(channel);
+ }
+
auto instruments = doc.createElement("instruments");
dgedit.appendChild(instruments);
@@ -129,6 +146,8 @@ QString ProjectSerialiser::serialise(const Project& project)
{
auto instrument = doc.createElement("instrument");
+ instrument.setAttribute("id", (int)i.getId());
+
instrument.setAttribute("attack_length", (int)i.getAttackLength());
instrument.setAttribute("power_spread", (int)i.getPowerSpread());
instrument.setAttribute("minimum_size", (int)i.getMinimumSize());
@@ -137,12 +156,11 @@ QString ProjectSerialiser::serialise(const Project& project)
instrument.setAttribute("threshold", i.getThreshold());
- instruments.appendChild(instrument);
+ auto prefix = doc.createElement("prefix");
+ prefix.appendChild(doc.createTextNode(i.getPrefix()));
+ instrument.appendChild(prefix);
- auto export_path = doc.createElement("export_path");
- export_path.setAttribute("prefix", i.getPrefix());
- export_path.appendChild(doc.createTextNode(i.export_path));
- instrument.appendChild(export_path);
+ instruments.appendChild(instrument);
auto instrument_name = doc.createElement("instrument_name");
instrument_name.appendChild(doc.createTextNode(i.instrument_name));
@@ -151,12 +169,14 @@ QString ProjectSerialiser::serialise(const Project& project)
auto file_list = doc.createElement("file_list");
instrument.appendChild(file_list);
- for(const auto& f : i.file_list)
+ for(const auto& audiofile : i.audio_files)
{
auto file = doc.createElement("file");
- file.appendChild(doc.createTextNode(f.first));
- file.setAttribute("name", f.second);
- file.setAttribute("master", i.master_file == f.first);
+ file.appendChild(doc.createTextNode(audiofile.getFile()));
+ file.setAttribute("id", audiofile.getId());
+ file.setAttribute("name", audiofile.getName());
+ file.setAttribute("channel_map_id", audiofile.getChannelMapId());
+ file.setAttribute("master", i.master_file == audiofile.getAbsoluteFile());
file_list.appendChild(file);
}
@@ -201,31 +221,47 @@ bool ProjectSerialiser::deserialise(const QString& data, Project& project)
return false;
}
+ project.next_id = dom["next_id"].toInt();
project.project_name = dom("project_name").text();
project.raw_file_root = dom("raw_file_root").text();
+ project.export_path = dom("export_path").text();
+
+ auto channels = dom("channels").children("channel");
+ for(auto& channel : channels)
+ {
+ auto id = channel["id"].toInt();
+ project.channels.emplace_back(Channel(project, id));
+
+ auto& ch = project.channels.back();
+ ch.channel_name = channel["name"];
+ }
auto instruments = dom("instruments").children("instrument");
for(auto& instrument : instruments)
{
- project.instruments.emplace_back(Instrument(project, project.next_id));
- ++project.next_id;
+ auto id = instrument["id"].toInt();
+ project.instruments.emplace_back(Instrument(project, id));
auto& instr = project.instruments.back();
instr.instrument_name = instrument("instrument_name").text();
QString master_file;
- AudioFileList file_list;
auto files = instrument("file_list").children("file");
for(auto& file : files)
{
+ auto id = file["id"].toInt();
+ instr.audio_files.emplace_back(AudioFile(instr, id));
+ auto& audiofile = instr.audio_files.back();
+ audiofile.file = file.text();
+ audiofile.name = file["name"];
+ audiofile.channel_map_id = file["channel_map_id"].toInt();
+
if(file["master"] == "1")
{
- master_file = file.text();
+ master_file = audiofile.getAbsoluteFile();
}
- file_list.push_back(qMakePair(file.text(), file["name"]));
}
- instr.file_list = file_list;
instr.master_file = master_file;
instr.attack_length = instrument["attack_length"].toInt();
@@ -236,8 +272,7 @@ bool ProjectSerialiser::deserialise(const QString& data, Project& project)
instr.threshold = instrument["threshold"].toFloat();
- instr.export_path = instrument("export_path").text();
- instr.prefix = instrument("export_path")["prefix"];
+ instr.prefix = instrument("prefix").text();
auto selections = instrument("regions");
instr.selections.nextid = selections["nextid"].toInt();