diff options
author | Sander Vocke <sandervocke@gmail.com> | 2024-07-25 09:09:35 +0200 |
---|---|---|
committer | Sander Vocke <sandervocke@gmail.com> | 2024-07-25 11:06:32 +0200 |
commit | 624aafbc9cde2b9e83c7c278e44f19ab9e3bc9fc (patch) | |
tree | f6e2ef7329b32e4601326012221e0b5ce64a0367 /src/midimapparser.cc | |
parent | 019d478818950f7880d2c0f80d8fc8f963e9736b (diff) |
Support curve maps in midi map file
Diffstat (limited to 'src/midimapparser.cc')
-rw-r--r-- | src/midimapparser.cc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/midimapparser.cc b/src/midimapparser.cc index 363e1d5..70dfbc0 100644 --- a/src/midimapparser.cc +++ b/src/midimapparser.cc @@ -25,10 +25,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "midimapparser.h" +#include "parsecurvemap.h" #include <pugixml.hpp> #include <hugin.hpp> +#include <cpp11fix.h> + bool MidiMapParser::parseFile(const std::string& filename) { pugi::xml_document doc; @@ -42,15 +45,26 @@ bool MidiMapParser::parseFile(const std::string& filename) pugi::xml_node midimap_node = doc.child("midimap"); for(pugi::xml_node map_node : midimap_node.children("map")) { - constexpr int bad_value = 10000; - auto note = map_node.attribute("note").as_int(bad_value); - auto instr = map_node.attribute("instr").as_string(); - if(std::string(instr) == "" || note == bad_value) + constexpr int default_int = 10000; + auto note = map_node.attribute("note").as_int(default_int); + auto instr = std::string(map_node.attribute("instr").as_string()); + + std::unique_ptr<CurveMap> maybe_curve; + auto maybe_curve_node = map_node.child("curve"); + if (maybe_curve_node) { + CurveMap curve; + if (parse_curve_map (maybe_curve_node, curve)) { + maybe_curve = std::make_unique<CurveMap>(); + *maybe_curve = curve; + } + } + + if(std::string(instr) == "" || note == default_int) { continue; } - MidimapEntry entry{note, instr}; + MidimapEntry entry(note, instr, maybe_curve.get()); midimap.push_back(entry); } |