summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2018-06-08 16:40:01 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2018-06-08 16:40:01 +0200
commit42003bd802d868182bf040e86f2cf2773b8ee851 (patch)
tree86c345b86d0d7567ee1301fb28f20bcc11e80f97
parentc00110f801ae9de05a7f4c250918e4c05588b1d9 (diff)
Add reset on double click for all the knobs.
-rw-r--r--plugingui/humanizerframecontent.cc19
-rw-r--r--plugingui/humanizerframecontent.h3
-rw-r--r--plugingui/knob.cc12
-rw-r--r--plugingui/knob.h2
-rw-r--r--plugingui/timingframecontent.cc59
-rw-r--r--plugingui/timingframecontent.h9
-rw-r--r--src/settings.h19
7 files changed, 98 insertions, 25 deletions
diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc
index dbb6007..51725d6 100644
--- a/plugingui/humanizerframecontent.cc
+++ b/plugingui/humanizerframecontent.cc
@@ -45,18 +45,21 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent,
attack.resize(80, 80);
attack_knob.resize(30, 30);
attack_knob.showValue(false);
+ attack_knob.setDefaultValue(Settings::velocity_modifier_weight_default);
attack.setControl(&attack_knob);
layout.addItem(&attack);
falloff.resize(80, 80);
falloff_knob.resize(30, 30);
falloff_knob.showValue(false);
+ falloff_knob.setDefaultValue(Settings::velocity_modifier_falloff_default);
falloff.setControl(&falloff_knob);
layout.addItem(&falloff);
stddev.resize(80, 80);
stddev_knob.resize(30, 30);
stddev_knob.showValue(false);
+ stddev_knob.setDefaultValue(stddevSettingsToKnob(Settings::velocity_stddev_default));
stddev.setControl(&stddev_knob);
layout.addItem(&stddev);
@@ -79,6 +82,16 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent,
this, &HumanizerframeContent::stddevKnobValueChanged);
}
+float HumanizerframeContent::stddevSettingsToKnob(float value)
+{
+ return (value - 0.5f) / 3.0f;
+}
+
+float HumanizerframeContent::stddevKnobToSettings(float value)
+{
+ return value * 3.0f + 0.5f;
+}
+
void HumanizerframeContent::attackValueChanged(float value)
{
settings.velocity_modifier_weight.store(value);
@@ -91,12 +104,14 @@ void HumanizerframeContent::falloffValueChanged(float value)
void HumanizerframeContent::stddevKnobValueChanged(float value)
{
- settings.velocity_stddev.store(value * 3.0f + 0.5f );
+ auto settings_value = stddevKnobToSettings(value);
+ settings.velocity_stddev.store(settings_value);
}
void HumanizerframeContent::stddevSettingsValueChanged(float value)
{
- stddev_knob.setValue((value - 0.5f) / 3.0f);
+ auto knob_value = stddevSettingsToKnob(value);
+ stddev_knob.setValue(knob_value);
}
} // GUI::
diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h
index 8286116..1fdc83c 100644
--- a/plugingui/humanizerframecontent.h
+++ b/plugingui/humanizerframecontent.h
@@ -46,6 +46,9 @@ public:
SettingsNotifier& settings_notifier);
private:
+ float stddevSettingsToKnob(float value);
+ float stddevKnobToSettings(float value);
+
void attackValueChanged(float value);
void falloffValueChanged(float value);
void stddevKnobValueChanged(float value);
diff --git a/plugingui/knob.cc b/plugingui/knob.cc
index 4082aa3..8e60056 100644
--- a/plugingui/knob.cc
+++ b/plugingui/knob.cc
@@ -61,6 +61,11 @@ void Knob::setValue(float value)
internalSetValue(value);
}
+void Knob::setDefaultValue(float value)
+{
+ default_value = value;
+}
+
void Knob::setRange(float minimum, float maximum)
{
this->minimum = minimum;
@@ -145,10 +150,16 @@ void Knob::buttonEvent(ButtonEvent* buttonEvent)
return;
}
+ if (buttonEvent->doubleClick) {
+ internalSetValue(default_value);
+ return;
+ }
+
if(buttonEvent->direction == Direction::down)
{
state = down;
mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y);
+ return;
}
if(buttonEvent->direction == Direction::up)
@@ -156,6 +167,7 @@ void Knob::buttonEvent(ButtonEvent* buttonEvent)
state = up;
mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y);
clicked();
+ return;
}
}
diff --git a/plugingui/knob.h b/plugingui/knob.h
index d8771d8..fc71511 100644
--- a/plugingui/knob.h
+++ b/plugingui/knob.h
@@ -44,6 +44,7 @@ public:
bool isFocusable() override { return true; }
void setValue(float value);
+ void setDefaultValue(float value);
void setRange(float minimum, float maximum);
float value();
void showValue(bool show_value);
@@ -72,6 +73,7 @@ private:
state_t state;
float current_value;
+ float default_value = 0.0;
float maximum;
float minimum;
diff --git a/plugingui/timingframecontent.cc b/plugingui/timingframecontent.cc
index fef4d33..3a29c6b 100644
--- a/plugingui/timingframecontent.cc
+++ b/plugingui/timingframecontent.cc
@@ -28,8 +28,6 @@
#include <cmath>
-#include <settings.h>
-
#include "painter.h"
namespace GUI
@@ -47,18 +45,21 @@ TimingframeContent::TimingframeContent(Widget* parent,
tightness.resize(80, 80);
tightness_knob.resize(30, 30);
tightness_knob.showValue(false);
+ tightness_knob.setDefaultValue(tightnessSettingsToKnob(Settings::latency_stddev_default));
tightness.setControl(&tightness_knob);
layout.addItem(&tightness);
regain.resize(80, 80);
regain_knob.resize(30, 30);
regain_knob.showValue(false);
+ regain_knob.setDefaultValue(Settings::latency_regain_default);
regain.setControl(&regain_knob);
layout.addItem(&regain);
laidback.resize(80, 80);
laidback_knob.resize(30, 30);
laidback_knob.showValue(false);
+ laidback_knob.setDefaultValue(laidbackSettingsToKnob(Settings::latency_laid_back_default));
laidback.setControl(&laidback_knob);
layout.addItem(&laidback);
// set range to [-1, 1]
@@ -85,20 +86,53 @@ TimingframeContent::TimingframeContent(Widget* parent,
}
-void TimingframeContent::tightnessKnobValueChanged(float value)
+float TimingframeContent::thightnessKnobToSettings(float value)
{
value -= 1.0f;
value *= -1.0f;
value *= 500.0f;
- settings.latency_stddev.store(value);
+
+ return value;
}
-void TimingframeContent::tightnessSettingsValueChanged(float value)
+float TimingframeContent::tightnessSettingsToKnob(float value)
{
value /= 500.0f;
value *= -1.0f;
value += 1.0f;
- tightness_knob.setValue(value);
+
+ return value;
+}
+
+float TimingframeContent::laidbackKnobToSettings(float value)
+{
+ value -= 0.5f;
+ value *= 2.0f;
+ value *= settings.latency_max.load();
+
+ return std::lround(value);
+}
+
+float TimingframeContent::laidbackSettingsToKnob(int int_value)
+{
+ float value = int_value;
+ value /= (float)settings.latency_max.load();
+ value *= 0.5;
+ value += 0.5;
+
+ return value;
+}
+
+void TimingframeContent::tightnessKnobValueChanged(float value)
+{
+ auto settings_value = thightnessKnobToSettings(value);
+ settings.latency_stddev.store(settings_value);
+}
+
+void TimingframeContent::tightnessSettingsValueChanged(float value)
+{
+ auto knob_value = tightnessSettingsToKnob(value);
+ tightness_knob.setValue(knob_value);
}
void TimingframeContent::regainKnobValueChanged(float value)
@@ -113,19 +147,14 @@ void TimingframeContent::regainSettingsValueChanged(float value)
void TimingframeContent::laidbackKnobValueChanged(float value)
{
- value -= 0.5f;
- value *= 2.0f;
- value *= settings.latency_max.load();
- settings.latency_laid_back.store(std::lround(value));
+ auto settings_value = laidbackKnobToSettings(value);
+ settings.latency_laid_back.store(settings_value);
}
void TimingframeContent::laidbackSettingsValueChanged(int int_value)
{
- float value = int_value;
- value /= (float)settings.latency_max.load();
- value *= 0.5;
- value += 0.5;
- laidback_knob.setValue(value);
+ auto knob_value = laidbackSettingsToKnob(int_value);
+ laidback_knob.setValue(knob_value);
}
} // GUI::
diff --git a/plugingui/timingframecontent.h b/plugingui/timingframecontent.h
index 6feeabe..dc2ad8b 100644
--- a/plugingui/timingframecontent.h
+++ b/plugingui/timingframecontent.h
@@ -28,15 +28,15 @@
#include "knob.h"
#include "label.h"
+#include "labeledcontrol.h"
#include "layout.h"
#include "widget.h"
-#include "labeledcontrol.h"
+#include <settings.h>
#include <iomanip>
#include <sstream>
-struct Settings;
class SettingsNotifier;
namespace GUI
@@ -51,6 +51,11 @@ public:
SettingsNotifier& settings_notifier);
private:
+ float thightnessKnobToSettings(float value);
+ float tightnessSettingsToKnob(float value);
+ float laidbackKnobToSettings(float value);
+ float laidbackSettingsToKnob(int int_value);
+
void tightnessKnobValueChanged(float value);
void tightnessSettingsValueChanged(float value);
void regainKnobValueChanged(float value);
diff --git a/src/settings.h b/src/settings.h
index c88dc95..65dbad3 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -71,9 +71,13 @@ struct Settings
Atomic<LoadStatus> midimap_load_status{LoadStatus::Idle};
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}; // [0.5; 3.0]
+
+ static float constexpr velocity_modifier_falloff_default = 0.5f;
+ static float constexpr velocity_modifier_weight_default = 0.25f;
+ static float constexpr velocity_stddev_default = 1.0f;
+ Atomic<float> velocity_modifier_falloff{velocity_modifier_falloff_default};
+ Atomic<float> velocity_modifier_weight{velocity_modifier_weight_default};
+ Atomic<float> velocity_stddev{velocity_stddev_default}; // [0.5; 3.0]
Atomic<bool> enable_velocity_randomiser{false};
Atomic<float> velocity_randomiser_weight{0.1f};
@@ -100,7 +104,8 @@ struct Settings
//! 0 := on-beat
//! positive := laid back
//! negative := up-beat
- Atomic<int> latency_laid_back{0};
+ static int constexpr latency_laid_back_default = 0;
+ Atomic<int> latency_laid_back{latency_laid_back_default};
//! 0 := Robot
//! 100 := Good drummer
@@ -108,12 +113,14 @@ struct Settings
//! 300 := Decent drummer on a bad day
//! 400 := Bad drummer
//! 500 := Bad and drunk drummer
- Atomic<float> latency_stddev{100.0f};
+ static float constexpr latency_stddev_default = 100.0f;
+ Atomic<float> latency_stddev{latency_stddev_default};
//! Regain on-beat position.
//! 0: instantaniously
//! 1: never
- Atomic<float> latency_regain{0.9f};
+ static float constexpr latency_regain_default = 0.9f;
+ Atomic<float> latency_regain{latency_regain_default};
};
//! Settings getter class.