diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-01-26 20:31:31 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2024-07-22 11:21:48 +0200 |
commit | a095aef4f9d2fe0584eeadca85039dbc838355ed (patch) | |
tree | 976dff233adbb073e2383593825a024d7b956a7b /src/dgxmlparser.cc | |
parent | 019d478818950f7880d2c0f80d8fc8f963e9736b (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")) |