From b360c7cf59cc87f79972fcdd82164834f97833b0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 10 Jun 2018 18:20:55 +0200 Subject: Add new DOMLoader class and unit-test. --- src/drumkitloader.cc | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/drumkitloader.cc') diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc index 02b2c13..0cef31b 100644 --- a/src/drumkitloader.cc +++ b/src/drumkitloader.cc @@ -35,6 +35,7 @@ #include "DGDOM.h" #include "dgxmlparser.h" #include "path.h" +#include "domloader.h" #define REFSFILE "refs.conf" @@ -134,12 +135,17 @@ bool DrumKitLoader::loadkit(const std::string& file) std::string path = getPath(edited_filename); bool parseerror = parseDrumkitFile(edited_filename, drumkitdom); - for(InstrumentRefDOM ref: drumkitdom.instruments) { + for(const auto& ref : drumkitdom.instruments) + { instrumentdoms.emplace_back(); - parseerror |= parseInstrumentFile(path + "/" + ref.file, instrumentdoms.back()); + parseerror &= parseInstrumentFile(path + "/" + ref.file, instrumentdoms.back()); } - if(parseerror) { + DOMLoader domloader(settings, rand); + parseerror &= domloader.loadDom(drumkitdom, instrumentdoms, kit); + + if(parseerror) + { ERR(drumgizmo, "Drumkit parser failed: %s\n", file.c_str()); settings.drumkit_load_status.store(LoadStatus::Error); @@ -150,18 +156,6 @@ 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)) //{ -- cgit v1.2.3