diff options
author | Jonas Suhr Christensen <jsc@umbraculum.org> | 2018-06-09 11:17:44 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-08-12 11:11:40 +0200 |
commit | 95bb01f326943a81a073a4bc1a7f3e21d1270fcc (patch) | |
tree | 589a105605e2aa599a0cbb60c41bded22efb665f /src/drumkitloader.cc | |
parent | 41fff35c4d22d9adc256e8309a87899a7a44f959 (diff) |
drumkitloader: use dgxmlparser for DOM creation
Diffstat (limited to 'src/drumkitloader.cc')
-rw-r--r-- | src/drumkitloader.cc | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc index 246e79b..02b2c13 100644 --- a/src/drumkitloader.cc +++ b/src/drumkitloader.cc @@ -30,9 +30,13 @@ #include <hugin.hpp> -#include "drumkitparser.h" #include "drumgizmo.h" #include "audioinputenginemidi.h" +#include "DGDOM.h" +#include "dgxmlparser.h" +#include "path.h" + +#define REFSFILE "refs.conf" DrumKitLoader::DrumKitLoader(Settings& settings, DrumKit& kit, AudioInputEngine& ie, @@ -105,9 +109,37 @@ bool DrumKitLoader::loadkit(const std::string& file) settings.drumkit_load_status.store(LoadStatus::Loading); - DrumKitParser parser(settings, kit, rand); - if(parser.parseFile(file)) + // Parse drumkit and instrument xml + + settings.has_bleed_control.store(false); + + ConfigFile refs(REFSFILE); + + auto edited_filename(file); + + if(refs.load()) + { + if((file.size() > 1) && (file[0] == '@')) + { + edited_filename = refs.getValue(file.substr(1)); + } + } + else { + ERR(drumkitparser, "Error reading refs.conf"); + } + + DrumkitDOM drumkitdom; + std::vector<InstrumentDOM> instrumentdoms; + std::string path = getPath(edited_filename); + bool parseerror = parseDrumkitFile(edited_filename, drumkitdom); + + for(InstrumentRefDOM ref: drumkitdom.instruments) { + instrumentdoms.emplace_back(); + parseerror |= parseInstrumentFile(path + "/" + ref.file, instrumentdoms.back()); + } + + if(parseerror) { ERR(drumgizmo, "Drumkit parser failed: %s\n", file.c_str()); settings.drumkit_load_status.store(LoadStatus::Error); @@ -118,6 +150,18 @@ bool DrumKitLoader::loadkit(const std::string& file) return false; } + //TODO: create + + kit._name = drumkitdom.name; + kit._description = drumkitdom.description; + kit._samplerate = drumkitdom.samplerate; + + for(auto& channel: drumkitdom.channels) { + kit.channels.emplace_back(); + kit.channels.back().name = channel.name; + kit.channels.back().num = kit.channels.size() -1; + } + // Check if there is enough free RAM to load the drumkit. //if(!memchecker.enoughFreeMemory(kit)) //{ |