From 34578fdef6a9f77aa285501130be55fcd560c03d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 10 Jul 2018 20:46:44 +0200 Subject: Use more sane range for stddev knob in UI. --- plugin/plugingizmo | 2 +- plugingui/humaniservisualiser.cc | 10 ++++++---- plugingui/humanizerframecontent.cc | 4 ++-- src/powerlist.cc | 17 +++++++++-------- src/settings.h | 2 +- src/staminafilter.cc | 11 ++++++++++- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/plugin/plugingizmo b/plugin/plugingizmo index efc2320..27ce655 160000 --- a/plugin/plugingizmo +++ b/plugin/plugingizmo @@ -1 +1 @@ -Subproject commit efc232050e3b3841f3d6c33cbc8e04a8c009bc88 +Subproject commit 27ce655dd74b81d40a3a28e65e753985f506a387 diff --git a/plugingui/humaniservisualiser.cc b/plugingui/humaniservisualiser.cc index 6737e36..5b5abb7 100644 --- a/plugingui/humaniservisualiser.cc +++ b/plugingui/humaniservisualiser.cc @@ -62,7 +62,7 @@ void HumaniserVisualiser::repaintEvent(GUI::RepaintEvent *repaintEvent) int x = latency_offset / 2000.0 * width() / 2 + width() / 2; int y = velocity_offset * height(); int w = latency_stddev / 10; - int h = velocity_stddev * 10; + int h = velocity_stddev * 20; // Stddev squares float v = w; @@ -72,7 +72,7 @@ void HumaniserVisualiser::repaintEvent(GUI::RepaintEvent *repaintEvent) a = a * a * a; p.setColour(GUI::Colour(1.0f, 0.0f, 1.0f, a)); p.drawFilledRectangle(x - v / 2, 0, - x + v / 2, height()); + x + v / 2 + 1, height()); v -= 1.0f; } @@ -83,7 +83,7 @@ void HumaniserVisualiser::repaintEvent(GUI::RepaintEvent *repaintEvent) a = a * a * a; p.setColour(GUI::Colour(1.0f, 0.0f, 1.0f, a)); p.drawFilledRectangle(0, y - v / 2, - width(), y + v / 2); + width(), y + v / 2 + 1); v -= 1.0f; } @@ -101,7 +101,8 @@ void HumaniserVisualiser::latencyOffsetChanged(int offset) void HumaniserVisualiser::velocityOffsetChanged(float offset) { - velocity_offset = -1 * offset + 1; + std::cout << "velocity_offset: " << offset << std::endl; + velocity_offset = -1.0f * offset + 1.0f; redraw(); } @@ -119,6 +120,7 @@ void HumaniserVisualiser::latencyLaidbackChanged(int laidback) void HumaniserVisualiser::velocityStddevChanged(float stddev) { + std::cout << "velocity_stddev: " << stddev << std::endl; velocity_stddev = stddev; redraw(); } diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc index 14c6929..5f84249 100644 --- a/plugingui/humanizerframecontent.cc +++ b/plugingui/humanizerframecontent.cc @@ -84,12 +84,12 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent, float HumanizerframeContent::stddevSettingsToKnob(float value) const { - return (value - 0.5f) / 8.0f; + return (value - 0.5f) / 4.0f; } float HumanizerframeContent::stddevKnobToSettings(float value) const { - return value * 8.0f + 0.5f; + return value * 4.0f + 0.5f; } void HumanizerframeContent::attackValueChanged(float value) 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 velocity_modifier_weight{velocity_modifier_weight_default}; Atomic velocity_stddev{velocity_stddev_default}; // [0.5; 3.0] - // Current velocity offset - for UI + // Current velocity offset - for UI Atomic velocity_modifier_current{1.0f}; Atomic 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; } -- cgit v1.2.3