From b6737efa307bb6dca6663bf8970dd0d444aa0af3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 7 Jun 2018 23:48:25 +0200 Subject: Store bleed control support in settings. --- src/drumkitparser.cc | 8 +++++++- src/drumkitparser.h | 2 +- src/instrumentparser.cc | 8 +++++++- src/instrumentparser.h | 6 +++++- src/settings.h | 5 +++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc index 2a49e47..d86957e 100644 --- a/src/drumkitparser.cc +++ b/src/drumkitparser.cc @@ -45,6 +45,8 @@ DrumKitParser::DrumKitParser(Settings& settings, DrumKit& k, Random& rand) int DrumKitParser::parseFile(const std::string& filename) { + settings.has_bleed_control.store(false); + auto edited_filename(filename); if(refs.load()) @@ -182,6 +184,10 @@ void DrumKitParser::startTag(const std::string& name, const attr_t& attr) { cattr.main_state = (attr.at("main") == "true") ? main_state_t::is_main : main_state_t::is_not_main; + if(cattr.main_state == main_state_t::is_main) + { + settings.has_bleed_control.store(true); + } } channelmap[attr.at("in")] = cattr; @@ -198,7 +204,7 @@ void DrumKitParser::endTag(const std::string& name) auto ptr = std::make_unique(settings, rand); ptr->setGroup(instr_group); - InstrumentParser parser(*ptr); + InstrumentParser parser(*ptr, settings); parser.parseFile(path + "/" + instr_file); // Transfer ownership to the DrumKit object. diff --git a/src/drumkitparser.h b/src/drumkitparser.h index e4645c3..c77b1ff 100644 --- a/src/drumkitparser.h +++ b/src/drumkitparser.h @@ -36,7 +36,7 @@ class DrumKitParser : public SAXParser { public: - DrumKitParser(Settings& setting, DrumKit& kit, Random& rand); + DrumKitParser(Settings& settings, DrumKit& kit, Random& rand); virtual ~DrumKitParser() = default; virtual int parseFile(const std::string& filename) override; diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc index f49a6af..9a5e36d 100644 --- a/src/instrumentparser.cc +++ b/src/instrumentparser.cc @@ -31,13 +31,15 @@ #include +#include "settings.h" #include "cpp11fix.h" #include "path.h" #include "nolocale.h" -InstrumentParser::InstrumentParser(Instrument& instrument) +InstrumentParser::InstrumentParser(Instrument& instrument, Settings& settings) : instrument(instrument) + , settings(settings) { } @@ -100,6 +102,10 @@ void InstrumentParser::startTag(const std::string& name, const attr_t& attr) { channel->main = (attr.at("main") == "true") ? main_state_t::is_main : main_state_t::is_not_main; + if(channel->main == main_state_t::is_main) + { + settings.has_bleed_control.store(true); + } } } diff --git a/src/instrumentparser.h b/src/instrumentparser.h index e87489f..f88f2ae 100644 --- a/src/instrumentparser.h +++ b/src/instrumentparser.h @@ -32,11 +32,13 @@ #include #include +class Settings; + class InstrumentParser : public SAXParser { public: - InstrumentParser(Instrument &instrument); + InstrumentParser(Instrument &instrument, Settings& settings); virtual ~InstrumentParser() = default; virtual int parseFile(const std::string& filename) override; @@ -57,4 +59,6 @@ private: level_t lower{0}; level_t upper{0}; + + Settings& settings; }; diff --git a/src/settings.h b/src/settings.h index 2f3569f..c88dc95 100644 --- a/src/settings.h +++ b/src/settings.h @@ -90,6 +90,7 @@ struct Settings Atomic enable_bleed_control{false}; Atomic master_bleed{1.0f}; + Atomic has_bleed_control{false}; Atomic enable_latency_modifier{true}; @@ -154,6 +155,7 @@ struct SettingsGetter SettingRef enable_bleed_control; SettingRef master_bleed; + SettingRef has_bleed_control; SettingRef enable_latency_modifier; SettingRef latency_max; @@ -190,6 +192,7 @@ struct SettingsGetter , current_file{settings.current_file} , enable_bleed_control{settings.enable_bleed_control} , master_bleed{settings.master_bleed} + , has_bleed_control{settings.has_bleed_control} , enable_latency_modifier{settings.enable_latency_modifier} , latency_max{settings.latency_max} , latency_laid_back{settings.latency_laid_back} @@ -239,6 +242,7 @@ public: Notifier enable_bleed_control; Notifier master_bleed; + Notifier has_bleed_control; Notifier enable_latency_modifier; Notifier latency_max; @@ -286,6 +290,7 @@ public: EVAL(enable_bleed_control); EVAL(master_bleed); + EVAL(has_bleed_control); EVAL(enable_latency_modifier); EVAL(latency_max); -- cgit v1.2.3