From 9c5efc23764522597a53a8745860cec54ea55d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Fri, 22 Mar 2019 01:09:15 +0100 Subject: Add settings and GUI for new sampling algorithm. --- plugingui/humanizerframecontent.cc | 82 +++++++++++++++++++++++++++++++------- plugingui/humanizerframecontent.h | 21 ++++++++-- plugingui/maintab.cc | 2 +- plugingui/maintab.h | 2 +- plugingui/testmain.cc | 4 +- 5 files changed, 90 insertions(+), 21 deletions(-) (limited to 'plugingui') diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc index 206d77d..db3fd97 100644 --- a/plugingui/humanizerframecontent.cc +++ b/plugingui/humanizerframecontent.cc @@ -59,13 +59,37 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent, stddev.resize(80, 80); stddev_knob.resize(30, 30); stddev_knob.showValue(false); - stddev_knob.setDefaultValue(stddevSettingsToKnob(Settings::velocity_stddev_default)); + stddev_knob.setDefaultValue(Settings::velocity_stddev_default/stddev_factor); stddev.setControl(&stddev_knob); layout.addItem(&stddev); + f_distance.resize(80, 80); + f_distance_knob.resize(30, 30); + f_distance_knob.showValue(false); + f_distance_knob.setDefaultValue(Settings::sample_selection_f_distance_default/f_distance_factor); + f_distance.setControl(&f_distance_knob); + layout.addItem(&f_distance); + + f_recent.resize(80, 80); + f_recent_knob.resize(30, 30); + f_recent_knob.showValue(false); + f_recent_knob.setDefaultValue(Settings::sample_selection_f_recent_default/f_recent_factor); + f_recent.setControl(&f_recent_knob); + layout.addItem(&f_recent); + + f_random.resize(80, 80); + f_random_knob.resize(30, 30); + f_random_knob.showValue(false); + f_random_knob.setDefaultValue(Settings::sample_selection_f_random_default/f_random_factor); + f_random.setControl(&f_random_knob); + layout.addItem(&f_random); + layout.setPosition(&attack, GridLayout::GridRange{0, 1, 0, 1}); layout.setPosition(&falloff, GridLayout::GridRange{1, 2, 0, 1}); layout.setPosition(&stddev, GridLayout::GridRange{2, 3, 0, 1}); + layout.setPosition(&f_distance, GridLayout::GridRange{0, 1, 1, 2}); + layout.setPosition(&f_recent, GridLayout::GridRange{1, 2, 1, 2}); + layout.setPosition(&f_random, GridLayout::GridRange{2, 3, 1, 2}); CONNECT(this, settings_notifier.velocity_modifier_weight, &attack_knob, &Knob::setValue); @@ -73,6 +97,12 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent, &falloff_knob, &Knob::setValue); CONNECT(this, settings_notifier.velocity_stddev, this, &HumanizerframeContent::stddevSettingsValueChanged); + CONNECT(this, settings_notifier.sample_selection_f_distance, + this, &HumanizerframeContent::fDistanceSettingsValueChanged); + CONNECT(this, settings_notifier.sample_selection_f_recent, + this, &HumanizerframeContent::fRecentSettingsValueChanged); + CONNECT(this, settings_notifier.sample_selection_f_random, + this, &HumanizerframeContent::fRandomSettingsValueChanged); CONNECT(&attack_knob, valueChangedNotifier, this, &HumanizerframeContent::attackValueChanged); @@ -80,38 +110,62 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent, this, &HumanizerframeContent::falloffValueChanged); CONNECT(&stddev_knob, valueChangedNotifier, this, &HumanizerframeContent::stddevKnobValueChanged); + CONNECT(&f_distance_knob, valueChangedNotifier, + this, &HumanizerframeContent::fDistanceKnobValueChanged); + CONNECT(&f_recent_knob, valueChangedNotifier, + this, &HumanizerframeContent::fRecentKnobValueChanged); + CONNECT(&f_random_knob, valueChangedNotifier, + this, &HumanizerframeContent::fRandomKnobValueChanged); } -float HumanizerframeContent::stddevSettingsToKnob(float value) const +void HumanizerframeContent::attackValueChanged(float value) { - return value / 4.5f; + settings.velocity_modifier_weight.store(value); } -float HumanizerframeContent::stddevKnobToSettings(float value) const +void HumanizerframeContent::falloffValueChanged(float value) { - return value * 4.5f; + settings.velocity_modifier_falloff.store(value); } -void HumanizerframeContent::attackValueChanged(float value) +void HumanizerframeContent::stddevKnobValueChanged(float value) { - settings.velocity_modifier_weight.store(value); + settings.velocity_stddev.store(value*stddev_factor); } -void HumanizerframeContent::falloffValueChanged(float value) +void HumanizerframeContent::fDistanceKnobValueChanged(float value) { - settings.velocity_modifier_falloff.store(value); + settings.sample_selection_f_distance.store(value*f_distance_factor); } -void HumanizerframeContent::stddevKnobValueChanged(float value) +void HumanizerframeContent::fRecentKnobValueChanged(float value) { - auto settings_value = stddevKnobToSettings(value); - settings.velocity_stddev.store(settings_value); + settings.sample_selection_f_recent.store(value*f_recent_factor); +} + +void HumanizerframeContent::fRandomKnobValueChanged(float value) +{ + settings.sample_selection_f_random.store(value*f_random_factor); } void HumanizerframeContent::stddevSettingsValueChanged(float value) { - auto knob_value = stddevSettingsToKnob(value); - stddev_knob.setValue(knob_value); + stddev_knob.setValue(value/stddev_factor); +} + +void HumanizerframeContent::fDistanceSettingsValueChanged(float value) +{ + f_distance_knob.setValue(value/f_distance_factor); +} + +void HumanizerframeContent::fRecentSettingsValueChanged(float value) +{ + f_recent_knob.setValue(value/f_recent_factor); +} + +void HumanizerframeContent::fRandomSettingsValueChanged(float value) +{ + f_random_knob.setValue(value/f_random_factor); } } // GUI:: diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h index 4befae0..e8c0810 100644 --- a/plugingui/humanizerframecontent.h +++ b/plugingui/humanizerframecontent.h @@ -46,23 +46,38 @@ public: SettingsNotifier& settings_notifier); private: - float stddevSettingsToKnob(float value) const; - float stddevKnobToSettings(float value) const; + static float constexpr stddev_factor = 4.5f; + static float constexpr f_distance_factor = 4.f; + static float constexpr f_recent_factor = 1.f; + static float constexpr f_random_factor = .5f; void attackValueChanged(float value); void falloffValueChanged(float value); void stddevKnobValueChanged(float value); + void fDistanceKnobValueChanged(float value); + void fRecentKnobValueChanged(float value); + void fRandomKnobValueChanged(float value); + void stddevSettingsValueChanged(float value); + void fDistanceSettingsValueChanged(float value); + void fRecentSettingsValueChanged(float value); + void fRandomSettingsValueChanged(float value); - GridLayout layout{this, 3, 1}; + GridLayout layout{this, 3, 2}; LabeledControl attack{this, "Attack"}; // drummer strength LabeledControl falloff{this, "Release"}; // regain LabeledControl stddev{this, "StdDev"}; + LabeledControl f_distance{this, "fDistance"}; + LabeledControl f_recent{this, "fRecent"}; + LabeledControl f_random{this, "fRandom"}; Knob attack_knob{&attack}; Knob falloff_knob{&falloff}; Knob stddev_knob{&stddev}; + Knob f_distance_knob{&f_distance}; + Knob f_recent_knob{&f_recent}; + Knob f_random_knob{&f_random}; Settings& settings; SettingsNotifier& settings_notifier; diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index 1cf445a..4b65092 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -52,7 +52,7 @@ MainTab::MainTab(Widget* parent, add("Status", status_frame, statusframe_content, 24, 0); add("Resampling", resampling_frame, resamplingframe_content, 10, 0); - add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 10, 1); + add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 20, 1); humanizer_frame.setHelpText("Hello World\nThis is a nice World\n... I think"); add("Timing Humanizer", timing_frame, timingframe_content, 10, 1); add("Visualizer", visualizer_frame, visualizerframe_content, 10, 1); diff --git a/plugingui/maintab.h b/plugingui/maintab.h index 7daa669..897326a 100644 --- a/plugingui/maintab.h +++ b/plugingui/maintab.h @@ -65,7 +65,7 @@ private: Image logo{":resources/logo.png"}; - GridLayout layout{this, 2, 49}; + GridLayout layout{this, 2, 59}; FrameWidget drumkit_frame{this, false}; FrameWidget status_frame{this, false}; diff --git a/plugingui/testmain.cc b/plugingui/testmain.cc index b122756..319abf6 100644 --- a/plugingui/testmain.cc +++ b/plugingui/testmain.cc @@ -57,9 +57,9 @@ int main() // TODO: automatically use drumgizmo_plugin.h size here #ifndef UI_PUGL - parent.resize(750, 613); + parent.resize(750, 733); #else - main_window.resize(750, 613); + main_window.resize(750, 733); #endif while(true) -- cgit v1.2.3