summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-07-18 16:46:13 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-07-18 16:46:13 +0200
commit04fc8205dc1cc471af9473162fdab48d0f39847b (patch)
tree9e8cd5c67928ae595d0c09e4f889d106626e18fa /plugingui
parenta0484778a9953dfd1948bf4dac71c51deab18cab (diff)
Store and use laidback setting in milliseconds.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/humaniservisualiser.cc9
-rw-r--r--plugingui/humaniservisualiser.h4
-rw-r--r--plugingui/timingframecontent.cc29
-rw-r--r--plugingui/timingframecontent.h4
4 files changed, 27 insertions, 19 deletions
diff --git a/plugingui/humaniservisualiser.cc b/plugingui/humaniservisualiser.cc
index a823c64..fd643d4 100644
--- a/plugingui/humaniservisualiser.cc
+++ b/plugingui/humaniservisualiser.cc
@@ -66,8 +66,9 @@ HumaniserVisualiser::Canvas::Canvas(GUI::Widget* parent,
SettingsNotifier& settings_notifier)
: GUI::Widget(parent)
, settings_notifier(settings_notifier)
- , latency_max_samples(settings.latency_max.load() *
+ , latency_max_samples(settings.latency_max_ms.load() *
settings.samplerate.load() / 1000)
+ , settings(settings)
{
CONNECT(this, settings_notifier.enable_latency_modifier,
this, &HumaniserVisualiser::Canvas::latencyEnabledChanged);
@@ -81,7 +82,7 @@ HumaniserVisualiser::Canvas::Canvas(GUI::Widget* parent,
CONNECT(this, settings_notifier.latency_stddev,
this, &HumaniserVisualiser::Canvas::latencyStddevChanged);
- CONNECT(this, settings_notifier.latency_laid_back,
+ CONNECT(this, settings_notifier.latency_laid_back_ms,
this, &HumaniserVisualiser::Canvas::latencyLaidbackChanged);
CONNECT(this, settings_notifier.velocity_stddev,
this, &HumaniserVisualiser::Canvas::velocityStddevChanged);
@@ -185,9 +186,9 @@ void HumaniserVisualiser::Canvas::latencyStddevChanged(float stddev)
redraw();
}
-void HumaniserVisualiser::Canvas::latencyLaidbackChanged(int laidback)
+void HumaniserVisualiser::Canvas::latencyLaidbackChanged(float laidback_ms)
{
- this->laidback = laidback;
+ this->laidback = laidback_ms * settings.samplerate.load() / 1000;
redraw();
}
diff --git a/plugingui/humaniservisualiser.h b/plugingui/humaniservisualiser.h
index 6ef39b9..576ae6f 100644
--- a/plugingui/humaniservisualiser.h
+++ b/plugingui/humaniservisualiser.h
@@ -66,7 +66,7 @@ private:
void latencyOffsetChanged(int offset);
void velocityOffsetChanged(float offset);
void latencyStddevChanged(float stddev);
- void latencyLaidbackChanged(int laidback);
+ void latencyLaidbackChanged(float laidback);
void velocityStddevChanged(float stddev);
GUI::Texture stddev_h{getImageCache(), ":resources/stddev_horizontal.png"};
@@ -84,6 +84,8 @@ private:
float velocity_stddev;
SettingsNotifier& settings_notifier;
const int latency_max_samples;
+
+ Settings& settings;
};
Canvas canvas;
diff --git a/plugingui/timingframecontent.cc b/plugingui/timingframecontent.cc
index d02f86f..0a8d6d4 100644
--- a/plugingui/timingframecontent.cc
+++ b/plugingui/timingframecontent.cc
@@ -60,7 +60,7 @@ TimingframeContent::TimingframeContent(Widget* parent,
laidback.resize(80, 80);
laidback_knob.resize(30, 30);
laidback_knob.showValue(false);
- laidback_knob.setDefaultValue(laidbackSettingsToKnob(Settings::latency_laid_back_default));
+ laidback_knob.setDefaultValue(laidbackSettingsToKnob(Settings::latency_laid_back_ms_default));
laidback.setControl(&laidback_knob);
layout.addItem(&laidback);
// set range to [-1, 1]
@@ -75,7 +75,7 @@ TimingframeContent::TimingframeContent(Widget* parent,
this, &TimingframeContent::tightnessSettingsValueChanged);
CONNECT(this, settings_notifier.latency_regain,
this, &TimingframeContent::regainSettingsValueChanged);
- CONNECT(this, settings_notifier.latency_laid_back,
+ CONNECT(this, settings_notifier.latency_laid_back_ms,
this, &TimingframeContent::laidbackSettingsValueChanged);
CONNECT(&tightness_knob, valueChangedNotifier,
@@ -104,20 +104,25 @@ float TimingframeContent::tightnessSettingsToKnob(float value) const
return value;
}
+
+static constexpr float laid_back_range = 100.0f;
+
float TimingframeContent::laidbackKnobToSettings(float value) const
{
+ // knob in range [0, 1] settings in +/- laid_back_range ms
value -= 0.5f;
- value *= 4.0f;
- value *= settings.latency_max.load();
+ value *= 2.0f;
+ value *= laid_back_range;
- return std::lround(value);
+ return value;
}
-float TimingframeContent::laidbackSettingsToKnob(int int_value) const
+float TimingframeContent::laidbackSettingsToKnob(float value) const
{
- float value = int_value;
- value /= (float)settings.latency_max.load();
- value /= 4.0f;
+ // settings in +/- laid_back_range ms knob in range [0, 1]
+
+ value /= laid_back_range;
+ value /= 2.0f;
value += 0.5f;
return value;
@@ -148,12 +153,12 @@ void TimingframeContent::regainSettingsValueChanged(float value)
void TimingframeContent::laidbackKnobValueChanged(float value)
{
auto settings_value = laidbackKnobToSettings(value);
- settings.latency_laid_back.store(settings_value);
+ settings.latency_laid_back_ms.store(settings_value);
}
-void TimingframeContent::laidbackSettingsValueChanged(int int_value)
+void TimingframeContent::laidbackSettingsValueChanged(float value)
{
- auto knob_value = laidbackSettingsToKnob(int_value);
+ auto knob_value = laidbackSettingsToKnob(value);
laidback_knob.setValue(knob_value);
}
diff --git a/plugingui/timingframecontent.h b/plugingui/timingframecontent.h
index a8ed62c..282f08f 100644
--- a/plugingui/timingframecontent.h
+++ b/plugingui/timingframecontent.h
@@ -54,14 +54,14 @@ private:
float thightnessKnobToSettings(float value) const;
float tightnessSettingsToKnob(float value) const;
float laidbackKnobToSettings(float value) const;
- float laidbackSettingsToKnob(int int_value) const;
+ float laidbackSettingsToKnob(float value) const;
void tightnessKnobValueChanged(float value);
void tightnessSettingsValueChanged(float value);
void regainKnobValueChanged(float value);
void regainSettingsValueChanged(float value);
void laidbackKnobValueChanged(float value);
- void laidbackSettingsValueChanged(int value);
+ void laidbackSettingsValueChanged(float value);
void latencyOffsetChanged(int offset);
void velocityOffsetChanged(float offset);