summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-11-05 12:49:16 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-11-05 12:49:16 +0100
commit424075047c41b06945801baca104a9ffb23032a3 (patch)
treedcd99c984adaa68c167892d46e6b018512df1b57 /src
parentf287d6244133c935f9b22f0e6302e42149ed88f3 (diff)
Add stddev scalar to sample selection.
Diffstat (limited to 'src')
-rw-r--r--src/instrument.cc2
-rw-r--r--src/powerlist.cc9
-rw-r--r--src/powerlist.h7
-rw-r--r--src/settings.h5
4 files changed, 19 insertions, 4 deletions
diff --git a/src/instrument.cc b/src/instrument.cc
index 466acc1..077ae55 100644
--- a/src/instrument.cc
+++ b/src/instrument.cc
@@ -33,7 +33,7 @@
Instrument::Instrument(Settings& settings, Random& rand)
: settings(settings)
, rand(rand)
- , powerlist(rand)
+ , powerlist(rand, settings)
{
DEBUG(instrument, "new %p\n", this);
mod = 1.0;
diff --git a/src/powerlist.cc b/src/powerlist.cc
index b5e7c84..37a13a3 100644
--- a/src/powerlist.cc
+++ b/src/powerlist.cc
@@ -38,6 +38,9 @@
#endif
#include <math.h>
+#include "random.h"
+#include "settings.h"
+
/**
* Minimum sample set size.
* Smaller means wider 'velocity groups'.
@@ -50,8 +53,9 @@ unsigned int const MIN_SAMPLE_SET_SIZE = 26u;
//#define AUTO_CALCULATE_POWER
unsigned int const LOAD_SIZE = 500u;
-PowerList::PowerList(Random& rand)
+PowerList::PowerList(Random& rand, Settings& settings)
: rand(rand)
+ , settings(settings)
{
power_max = 0;
power_min = 100000000;
@@ -204,6 +208,8 @@ void PowerList::finalise()
Sample* PowerList::get(level_t level)
{
+ auto velocity_stddev = settings.velocity_stddev.load();
+
if(!samples.size())
{
return nullptr; // No samples to choose from.
@@ -226,6 +232,7 @@ Sample* PowerList::get(level_t level)
// Cut off mean value with stddev/2 in both ends in order to make room for
// downwards expansion on velocity 0 and upwards expansion on velocity 1.
float mean = level * (power_span - stddev) + (stddev / 2.0);
+ stddev *= velocity_stddev;
float power{0.f};
diff --git a/src/powerlist.h b/src/powerlist.h
index 9066ce1..b0938af 100644
--- a/src/powerlist.h
+++ b/src/powerlist.h
@@ -29,12 +29,14 @@
#include <vector>
#include "sample.h"
-#include "random.h"
+
+class Random;
+class Settings;
class PowerList
{
public:
- PowerList(Random& rand);
+ PowerList(Random& rand, Settings& settings);
void add(Sample* s);
void finalise(); ///< Call this when no more samples will be added.
@@ -49,6 +51,7 @@ private:
};
Random& rand;
+ Settings& settings;
std::vector<PowerListItem> samples;
float power_max;
diff --git a/src/settings.h b/src/settings.h
index 0b73cf2..8f7c057 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -73,6 +73,7 @@ struct Settings
Atomic<bool> enable_velocity_modifier{true};
Atomic<float> velocity_modifier_falloff{0.5f};
Atomic<float> velocity_modifier_weight{0.25f};
+ Atomic<float> velocity_stddev{1.0f};
Atomic<bool> enable_velocity_randomiser{false};
Atomic<float> velocity_randomiser_weight{0.1f};
@@ -113,6 +114,7 @@ struct SettingsGetter
SettingRef<bool> enable_velocity_modifier;
SettingRef<float> velocity_modifier_falloff;
SettingRef<float> velocity_modifier_weight;
+ SettingRef<float> velocity_stddev;
SettingRef<bool> enable_velocity_randomiser;
SettingRef<float> velocity_randomiser_weight;
@@ -147,6 +149,7 @@ struct SettingsGetter
, enable_velocity_modifier{settings.enable_velocity_modifier}
, velocity_modifier_falloff{settings.velocity_modifier_falloff}
, velocity_modifier_weight{settings.velocity_modifier_weight}
+ , velocity_stddev{settings.velocity_stddev}
, enable_velocity_randomiser{settings.enable_velocity_randomiser}
, velocity_randomiser_weight{settings.velocity_randomiser_weight}
, samplerate{settings.samplerate}
@@ -185,6 +188,7 @@ public:
Notifier<bool> enable_velocity_modifier;
Notifier<float> velocity_modifier_falloff;
Notifier<float> velocity_modifier_weight;
+ Notifier<float> velocity_stddev;
Notifier<bool> enable_velocity_randomiser;
Notifier<float> velocity_randomiser_weight;
@@ -225,6 +229,7 @@ public:
EVAL(enable_velocity_modifier);
EVAL(velocity_modifier_falloff);
EVAL(velocity_modifier_weight);
+ EVAL(velocity_stddev);
EVAL(enable_velocity_randomiser);
EVAL(velocity_randomiser_weight);