summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-04-01 13:58:10 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2017-04-01 21:00:39 +0200
commit32ad5ff14a03cdf049903523603c6b7a83dd7a5a (patch)
tree7e023729dd2a3adccd947f5beb6ef7f547f79388
parentee324cd887455f3ea456572ef6d8b627f6dd0bb3 (diff)
Store new setting in the plugin.
-rw-r--r--plugin/drumgizmo_plugin.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/plugin/drumgizmo_plugin.cc b/plugin/drumgizmo_plugin.cc
index d6dd371..9b1c46d 100644
--- a/plugin/drumgizmo_plugin.cc
+++ b/plugin/drumgizmo_plugin.cc
@@ -28,6 +28,7 @@
#include <cstring>
#include <algorithm>
+#include <string>
#include <midievent.h>
@@ -463,6 +464,13 @@ std::string bool2str(bool a)
return a?"true":"false";
}
+std::string int2str(int a)
+{
+ char buf[256];
+ snprintf(buf, sizeof(buf) - 1, "%d", a);
+ return buf;
+}
+
float str2float(std::string a)
{
if(a == "")
@@ -473,6 +481,18 @@ float str2float(std::string a)
return atof_nol(a.c_str());
}
+int str2int(std::string a)
+{
+ try
+ {
+ return std::stoi(a);
+ }
+ catch(...)
+ {
+ return 0;
+ }
+}
+
} // end anonymous namespace
DrumGizmoPlugin::ConfigStringIO::ConfigStringIO(Settings& settings)
@@ -498,7 +518,9 @@ std::string DrumGizmoPlugin::ConfigStringIO::get()
" <value name=\"velocity_randomiser_weight\">" +
float2str(settings.velocity_randomiser_weight.load()) + "</value>\n"
" <value name=\"disk_cache_upper_limit\">" +
- float2str(settings.disk_cache_upper_limit.load()) + "</value>\n"
+ int2str(settings.disk_cache_upper_limit.load()) + "</value>\n"
+ " <value name=\"disk_cache_chunk_size\">" +
+ int2str(settings.disk_cache_chunk_size.load()) + "</value>\n"
" <value name=\"disk_cache_enable\">" +
bool2str(settings.disk_cache_enable.load()) + "</value>\n"
"</config>";
@@ -547,7 +569,12 @@ bool DrumGizmoPlugin::ConfigStringIO::set(std::string config_string)
if(p.value("disk_cache_upper_limit") != "")
{
- settings.disk_cache_upper_limit.store(str2float(p.value("disk_cache_upper_limit")));
+ settings.disk_cache_upper_limit.store(str2int(p.value("disk_cache_upper_limit")));
+ }
+
+ if(p.value("disk_cache_chunk_size") != "")
+ {
+ settings.disk_cache_chunk_size.store(str2int(p.value("disk_cache_chunk_size")));
}
if(p.value("disk_cache_enable") != "")