diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-01-26 20:31:31 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-01-27 16:37:32 +0100 |
commit | a90ae034154b10bb81c74940504a1edca541db7a (patch) | |
tree | 384a34a28c4f7a61901c574a381e213be55daf1c /src/dgxmlparser.cc | |
parent | d1d53e5a83d981e190aed52b95a18f6ffa0d784f (diff) |
Add positional information to drumkit xml and sample class.
Diffstat (limited to 'src/dgxmlparser.cc')
-rw-r--r-- | src/dgxmlparser.cc | 16 |
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")) |