From 2aae9799e1d96d827ad156aeafa549deabd51e5d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 27 Jan 2019 17:02:40 +0100 Subject: Re-instate instrument v1.0 support. --- src/domloader.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/domloader.cc') diff --git a/src/domloader.cc b/src/domloader.cc index 663ef75..8a133fa 100644 --- a/src/domloader.cc +++ b/src/domloader.cc @@ -165,6 +165,35 @@ bool DOMLoader::loadDom(const std::string& basepath, } } + if(instrument->version == VersionStr(1,0,0)) + { + // Version 1.0 use velocity groups + for(auto& velocity : instrumentdom.velocities) + { + for(const auto& sampleref : velocity.samplerefs) + { + bool found_sample{false}; + for(const auto& sample : instrument->samplelist) + { + // TODO: What should be done with the probability?? + if(sample->name == sampleref.name) + { + instrument->addSample(velocity.lower, velocity.upper, sample); + found_sample = true; + break; + } + } + if(!found_sample) + { + ERR(kitparser, + "Missing sample '%s' from sampleref in instrument '%s'\n", + sampleref.name.data(), instrument->getName().data()); + return false; + } + } + } + } + instrument->finalise(); // Transfer ownership to the DrumKit object. -- cgit v1.2.3