diff options
-rw-r--r-- | src/drumkit.h | 1 | ||||
-rw-r--r-- | src/drumkitloader.cc | 50 |
2 files changed, 48 insertions, 3 deletions
diff --git a/src/drumkit.h b/src/drumkit.h index ae3a49b..1786584 100644 --- a/src/drumkit.h +++ b/src/drumkit.h @@ -36,6 +36,7 @@ class DrumKit { friend class DrumKitParser; + friend class DrumKitLoader; public: DrumKit(); ~DrumKit(); 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)) //{ |