summaryrefslogtreecommitdiff
path: root/src/dgxmlparser.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-01-27 17:02:40 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2019-01-27 17:02:40 +0100
commit2aae9799e1d96d827ad156aeafa549deabd51e5d (patch)
tree707fb2798cd3b9304fc4af690b557efc9d98a1a8 /src/dgxmlparser.cc
parent053b723adf3948d18f025efed9450d837359edd9 (diff)
Re-instate instrument v1.0 support.
Diffstat (limited to 'src/dgxmlparser.cc')
-rw-r--r--src/dgxmlparser.cc46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/dgxmlparser.cc b/src/dgxmlparser.cc
index 9d3249e..fc5dbb9 100644
--- a/src/dgxmlparser.cc
+++ b/src/dgxmlparser.cc
@@ -179,20 +179,56 @@ bool parseInstrumentFile(const std::string& filename, InstrumentDOM& dom)
res &= attrcpy(dom.instrument_channels.back().main, channel, "main", true);
}
+ INFO(dgxmlparser, "XML version: %s\n", dom.version.data());
+
pugi::xml_node samples = instrument.child("samples");
for(pugi::xml_node sample: samples.children("sample"))
{
dom.samples.emplace_back();
res &= attrcpy(dom.samples.back().name, sample, "name");
- res &= attrcpy(dom.samples.back().power, sample, "power");
+
+ // Power only part of >= v2.0 instruments.
+ if(dom.version == "1.0")
+ {
+ dom.samples.back().power = 0.0;
+ }
+ else
+ {
+ res &= attrcpy(dom.samples.back().power, sample, "power");
+ }
for(pugi::xml_node audiofile: sample.children("audiofile"))
{
dom.samples.back().audiofiles.emplace_back();
- res &= attrcpy(dom.samples.back().audiofiles.back().instrument_channel, audiofile, "channel");
- res &= attrcpy(dom.samples.back().audiofiles.back().file, audiofile, "file");
- dom.samples.back().audiofiles.back().filechannel = 1; // Defaults to channel 1 in mono (1-based)
- res &= attrcpy(dom.samples.back().audiofiles.back().filechannel, audiofile, "filechannel", true);
+ res &= attrcpy(dom.samples.back().audiofiles.back().instrument_channel,
+ audiofile, "channel");
+ res &= attrcpy(dom.samples.back().audiofiles.back().file,
+ audiofile, "file");
+ // Defaults to channel 1 in mono (1-based)
+ dom.samples.back().audiofiles.back().filechannel = 1;
+ res &= attrcpy(dom.samples.back().audiofiles.back().filechannel,
+ audiofile, "filechannel", true);
+ }
+ }
+
+ // Velocity groups are only part of v1.0 instruments.
+ if(dom.version == "1.0")
+ {
+ pugi::xml_node velocities = instrument.child("velocities");
+ for(pugi::xml_node velocity: velocities.children("velocity"))
+ {
+ dom.velocities.emplace_back();
+
+ res &= attrcpy(dom.velocities.back().lower, velocity, "lower");
+ res &= attrcpy(dom.velocities.back().upper, velocity, "upper");
+ for(pugi::xml_node sampleref: velocity.children("sampleref"))
+ {
+ dom.velocities.back().samplerefs.emplace_back();
+ res &= attrcpy(dom.velocities.back().samplerefs.back().probability,
+ sampleref, "probability");
+ res &= attrcpy(dom.velocities.back().samplerefs.back().name,
+ sampleref, "name");
+ }
}
}