summaryrefslogtreecommitdiff
path: root/src/dgxmlparser.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-01-26 20:31:31 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2021-08-09 19:24:06 +0200
commit3329f636502bb4000c7a0da208bea42545564052 (patch)
treefc3cfd2f72d30d6a767b01cbfe064e0ca423b354 /src/dgxmlparser.cc
parent380213d0a092a874182f1cf9c8d0cf828a624511 (diff)
Add positional information to drumkit xml and sample class.
Diffstat (limited to 'src/dgxmlparser.cc')
-rw-r--r--src/dgxmlparser.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/dgxmlparser.cc b/src/dgxmlparser.cc
index 0d3cdcd..bd9af66 100644
--- a/src/dgxmlparser.cc
+++ b/src/dgxmlparser.cc
@@ -358,9 +358,19 @@ bool parseInstrumentFile(const std::string& filename, InstrumentDOM& dom, LogFun
}
else
{
- res &= attrcpy(dom.samples.back().power, sample, "power", logger, filename);
- dom.samples.back().normalized = false;
- res &= attrcpy(dom.samples.back().normalized, sample, "normalized", logger, filename, true);
+ res &= attrcpy(dom.samples.back().power, sample, "power",
+ logger, filename);
+
+ dom.samples.back().position = 0.0; // optional - defaults to 0
+ res &= attrcpy(dom.samples.back().position, sample, "position",
+ logger, filename, true);
+ // Clamp to [0; 1] range.
+ dom.samples.back().position =
+ std::min(1.0, std::max(dom.samples.back().position, 0.0));
+
+ dom.samples.back().normalized = false; // optional - defaults to false
+ res &= attrcpy(dom.samples.back().normalized, sample, "normalized",
+ logger, filename, true);
}
for(pugi::xml_node audiofile: sample.children("audiofile"))