summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-07-10 20:46:44 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-07-15 18:56:01 +0200
commit34578fdef6a9f77aa285501130be55fcd560c03d (patch)
treedf7336fb49652c4e34297d6a53a7cc239e0ddd99 /src
parentbe9fe821ff1689ece9ee6433fcf42ec316e0aaad (diff)
Use more sane range for stddev knob in UI.
Diffstat (limited to 'src')
-rw-r--r--src/powerlist.cc17
-rw-r--r--src/settings.h2
-rw-r--r--src/staminafilter.cc11
3 files changed, 20 insertions, 10 deletions
diff --git a/src/powerlist.cc b/src/powerlist.cc
index 37a13a3..5ce9404 100644
--- a/src/powerlist.cc
+++ b/src/powerlist.cc
@@ -47,7 +47,7 @@
* Limited by sample set size, ie. only kicks in if sample set size is smaller
* than this number.
*/
-unsigned int const MIN_SAMPLE_SET_SIZE = 26u;
+std::size_t const MIN_SAMPLE_SET_SIZE = 26u;
// Enable to calculate power on old samples without power attribute
//#define AUTO_CALCULATE_POWER
@@ -221,18 +221,18 @@ Sample* PowerList::get(level_t level)
float power_span = power_max - power_min;
- // Width is limited to at least 10. Fioxes problem with instrument with a
+ // Width is limited to at least 10. Fixes problem with instrument with a
// sample set smaller than MIN_SAMPLE_SET_SIZE.
- float width = fmax(samples.size(), MIN_SAMPLE_SET_SIZE);
+ float width = std::max(samples.size(), MIN_SAMPLE_SET_SIZE);
// Spread out at most ~2 samples away from center if all samples have a
// uniform distribution over the power spectrum (which they probably don't).
- float stddev = power_span / width;
+ float mean_stepwidth = power_span / width;
// 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 mean = level * (power_span - mean_stepwidth) + (mean_stepwidth / 2.0);
+ float stddev = velocity_stddev * mean_stepwidth;
float power{0.f};
@@ -249,8 +249,9 @@ Sample* PowerList::get(level_t level)
// (power_min+stddev/2) and (power_max-stddev/2)
lvl += power_min;
- DEBUG(rand, "level: %f, lvl: %f (mean: %.2f, stddev: %.2f)\n", level, lvl,
- mean, stddev);
+ DEBUG(rand,
+ "level: %f, lvl: %f (mean: %.2f, stddev: %.2f, mean_stepwidth: %f, power_min: %f, power_max: %f)\n",
+ level, lvl, mean, stddev, mean_stepwidth, power_min, power_max);
for (auto& item: samples)
{
diff --git a/src/settings.h b/src/settings.h
index 9d225b0..0d76cfc 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -79,7 +79,7 @@ struct Settings
Atomic<float> velocity_modifier_weight{velocity_modifier_weight_default};
Atomic<float> velocity_stddev{velocity_stddev_default}; // [0.5; 3.0]
- // Current velocity offset - for UI
+ // Current velocity offset - for UI
Atomic<float> velocity_modifier_current{1.0f};
Atomic<bool> enable_velocity_randomiser{false};
diff --git a/src/staminafilter.cc b/src/staminafilter.cc
index aadfd2d..8fdbfbb 100644
--- a/src/staminafilter.cc
+++ b/src/staminafilter.cc
@@ -76,7 +76,16 @@ bool StaminaFilter::filter(event_t& event, size_t pos)
mod *= velocity_modifier_weight;
}
- settings.velocity_modifier_current.store(mod);
+ {
+ auto velocity_modifier_current = settings.velocity_modifier_current.load();
+ float p = 0.9f;
+ float new_value = mod * p + velocity_modifier_current * (1.0f - p);
+ if(mod > new_value)
+ {
+ new_value = mod;
+ }
+ settings.velocity_modifier_current.store(new_value);
+ }
return true;
}