From f653c5348904d8debc84f6c0e72d17430579204e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sat, 16 Jul 2016 15:46:40 +0200 Subject: Move config io from DrumGizmo to DrumGizmoPlugin (into own class). Drumkit file and midimap file are now fetched from settings instead of DrumGizmo members. --- src/drumgizmo.cc | 110 +------------------------------------------------------ src/drumgizmo.h | 5 --- 2 files changed, 1 insertion(+), 114 deletions(-) (limited to 'src') diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index b6d464f..fa601e6 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -37,16 +37,13 @@ #include -#include #include +#include #include #include "drumkitparser.h" #include "audioinputenginemidi.h" -#include "configparser.h" - -#include "nolocale.h" DrumGizmo::DrumGizmo(Settings& settings, AudioOutputEngine& o, AudioInputEngine& i) @@ -411,108 +408,3 @@ void DrumGizmo::setSamplerate(int samplerate) } #endif/*WITH_RESAMPLER*/ } - -std::string float2str(float a) -{ - char buf[256]; - snprintf_nol(buf, sizeof(buf) - 1, "%f", a); - return buf; -} - -std::string bool2str(bool a) -{ - return a?"true":"false"; -} - -float str2float(std::string a) -{ - if(a == "") - { - return 0.0; - } - - return atof_nol(a.c_str()); -} - -std::string DrumGizmo::configString() -{ - std::string mmapfile; - auto midiEngine = dynamic_cast(&ie); - if(midiEngine) - { - mmapfile = midiEngine->getMidimapFile(); - } - - return - "\n" - " " + kit.getFile() + "\n" - " " + mmapfile + "\n" - " " + - bool2str(settings.enable_velocity_modifier.load()) + "\n" - " " + - float2str(settings.velocity_modifier_falloff.load()) + "\n" - " " + - float2str(settings.velocity_modifier_weight.load()) + "\n" - " " + - bool2str(settings.enable_velocity_randomiser.load()) + "\n" - " " + - float2str(settings.velocity_randomiser_weight.load()) + "\n" - ""; -} - -bool DrumGizmo::setConfigString(std::string cfg) -{ - DEBUG(config, "Load config: %s\n", cfg.c_str()); - - std::string dkf; - ConfigParser p; - if(p.parseString(cfg)) - { - ERR(drumgizmo, "Config parse error.\n"); - return false; - } - - if(p.value("enable_velocity_modifier") != "") - { - settings.enable_velocity_modifier.store(p.value("enable_velocity_modifier") == "true"); - } - - if(p.value("velocity_modifier_falloff") != "") - { - settings.velocity_modifier_falloff.store(str2float(p.value("velocity_modifier_falloff"))); - } - - if(p.value("velocity_modifier_weight") != "") - { - settings.velocity_modifier_weight.store(str2float(p.value("velocity_modifier_weight"))); - } - - if(p.value("enable_velocity_randomiser") != "") - { - settings.enable_velocity_randomiser.store(p.value("enable_velocity_randomiser") == "true"); - } - - if(p.value("velocity_randomiser_weight") != "") - { - settings.velocity_randomiser_weight.store(str2float(p.value("velocity_randomiser_weight"))); - } - - if(p.value("enable_resampling") != "") - { - settings.enable_resampling.store(p.value("enable_resampling") == "true"); - } - - std::string newkit = p.value("drumkitfile"); - if(newkit != "") - { - settings.drumkit_file.store(newkit); - } - - std::string newmidimap = p.value("midimapfile"); - if(newmidimap != "") - { - settings.midimap_file.store(newmidimap); - } - - return true; -} diff --git a/src/drumgizmo.h b/src/drumgizmo.h index 8ad77d3..b104772 100644 --- a/src/drumgizmo.h +++ b/src/drumgizmo.h @@ -39,7 +39,6 @@ #include "audiocache.h" #include "mutex.h" #include "chresampler.h" -#include "configfile.h" #include "settings.h" #include "inputprocessor.h" @@ -60,9 +59,6 @@ public: void getSamples(int ch, int pos, sample_t *s, size_t sz); - std::string configString(); - bool setConfigString(std::string cfg); - //! Get the current engine latency in samples. std::size_t getLatency() const; @@ -105,6 +101,5 @@ protected: std::vector events; Settings& settings; - SettingsGetter getter{settings}; Random rand; }; -- cgit v1.2.3