summaryrefslogtreecommitdiff
path: root/plugingui/timingframecontent.cc
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 /plugingui/timingframecontent.cc
parentc00110f801ae9de05a7f4c250918e4c05588b1d9 (diff)
Add reset on double click for all the knobs.
Diffstat (limited to 'plugingui/timingframecontent.cc')
-rw-r--r--plugingui/timingframecontent.cc59
1 files changed, 44 insertions, 15 deletions
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::