summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-10-14 19:42:48 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-02-18 11:43:42 +0100
commitc3cb642947c42de48a64e79b15af77ff900d2491 (patch)
tree794782bf243bafa26a6ae103a9e9ede8c2c76d21 /plugingui
parent6a90e6c24f05c57cdbe19e5cc44c77c9e5810148 (diff)
Added latency filter UI controls.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/Makefile.am2
-rw-r--r--plugingui/humanizerframecontent.h5
-rw-r--r--plugingui/maintab.cc25
-rw-r--r--plugingui/maintab.h4
-rw-r--r--plugingui/testmain.cc2
-rw-r--r--plugingui/timingframecontent.cc131
-rw-r--r--plugingui/timingframecontent.h75
7 files changed, 236 insertions, 8 deletions
diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am
index c8004b0..714b21c 100644
--- a/plugingui/Makefile.am
+++ b/plugingui/Makefile.am
@@ -92,6 +92,7 @@ nodist_libdggui_la_SOURCES = \
textedit.cc \
texture.cc \
texturedbox.cc \
+ timingframecontent.cc \
toggle.cc \
utf8.cc \
verticalline.cc \
@@ -189,6 +190,7 @@ EXTRA_DIST = \
textedit.h \
texture.h \
texturedbox.h \
+ timingframecontent.h \
toggle.h \
utf8.h \
verticalline.h \
diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h
index 61ba73b..a9e0750 100644
--- a/plugingui/humanizerframecontent.h
+++ b/plugingui/humanizerframecontent.h
@@ -69,6 +69,9 @@ public:
layout.addItem(&value);
}
+ float offset{0.0f};
+ float scale{1.0f};
+
private:
VBoxLayout layout{this};
Label caption{this};
@@ -76,6 +79,8 @@ private:
void setValue(float new_value)
{
+ new_value *= scale;
+ new_value += offset;
std::stringstream stream;
stream << std::fixed << std::setprecision(2) << new_value;
value.setText(stream.str());
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
index 8b6e478..84e8a92 100644
--- a/plugingui/maintab.cc
+++ b/plugingui/maintab.cc
@@ -40,22 +40,26 @@ MainTab::MainTab(Widget* parent,
, diskstreamingframe_content{this, settings, settings_notifier}
, bleedcontrolframe_content{this, settings, settings_notifier}
, resamplingframe_content{this, settings_notifier}
+ , timingframe_content{this, settings, settings_notifier}
, settings(settings)
, settings_notifier(settings_notifier)
{
layout.setSpacing(0);
layout.setResizeChildren(true);
- add("Drumkit", drumkit_frame, drumkitframe_content, 20, 0);
- add("Status", status_frame, statusframe_content, 29, 0);
- add("Humanizer", humanizer_frame, humanizerframe_content, 13, 1);
- add("Disk Streaming", diskstreaming_frame, diskstreamingframe_content, 11, 1);
- add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 11, 1);
- add("Resampling", resampling_frame, resamplingframe_content, 14, 1);
+ add("Drumkit", drumkit_frame, drumkitframe_content, 15, 0);
+ add("Status", status_frame, statusframe_content, 24, 0);
+ add("Disk Streaming", diskstreaming_frame, diskstreamingframe_content, 10, 0);
+
+ add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 12, 1);
+ add("Timing Humanizer", timing_frame, timingframe_content, 12, 1);
+ add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 10, 1);
+ add("Resampling", resampling_frame, resamplingframe_content, 15, 1);
humanizer_frame.setOnSwitch(settings.enable_velocity_modifier);
bleedcontrol_frame.setOnSwitch(settings.enable_bleed_control);
resampling_frame.setOnSwitch(settings.enable_resampling);
+ timing_frame.setOnSwitch(settings.enable_latency_modifier);
CONNECT(this, settings_notifier.enable_velocity_modifier,
&humanizer_frame, &FrameWidget::setOnSwitch);
@@ -67,6 +71,8 @@ MainTab::MainTab(Widget* parent,
this, &MainTab::bleedcontrolOnChange);
CONNECT(&resampling_frame, onSwitchChangeNotifier,
this, &MainTab::resamplingOnChange);
+ CONNECT(&timing_frame, onSwitchChangeNotifier,
+ this, &MainTab::timingOnChange);
}
void MainTab::resize(std::size_t width, std::size_t height)
@@ -94,8 +100,13 @@ void MainTab::resamplingOnChange(bool on)
settings.enable_resampling.store(on);
}
+void MainTab::timingOnChange(bool on)
+{
+ settings.enable_latency_modifier.store(on);
+}
+
void MainTab::add(std::string const& title, FrameWidget& frame, Widget& content,
- std::size_t height, int column)
+ std::size_t height, int column)
{
layout.addItem(&frame);
frame.setTitle(title);
diff --git a/plugingui/maintab.h b/plugingui/maintab.h
index ce1e5b4..c52205b 100644
--- a/plugingui/maintab.h
+++ b/plugingui/maintab.h
@@ -35,6 +35,7 @@
#include "diskstreamingframecontent.h"
#include "bleedcontrolframecontent.h"
#include "resamplingframecontent.h"
+#include "timingframecontent.h"
struct Settings;
class SettingsNotifier;
@@ -59,6 +60,7 @@ private:
void humanizerOnChange(bool on);
void bleedcontrolOnChange(bool on);
void resamplingOnChange(bool on);
+ void timingOnChange(bool on);
Image logo{":resources/logo.png"};
@@ -70,6 +72,7 @@ private:
FrameWidget diskstreaming_frame{this, false};
FrameWidget bleedcontrol_frame{this, true};
FrameWidget resampling_frame{this, true};
+ FrameWidget timing_frame{this, true};
DrumkitframeContent drumkitframe_content;
StatusframeContent statusframe_content;
@@ -77,6 +80,7 @@ private:
DiskstreamingframeContent diskstreamingframe_content;
BleedcontrolframeContent bleedcontrolframe_content;
ResamplingframeContent resamplingframe_content;
+ TimingframeContent timingframe_content;
void add(std::string const& title, FrameWidget& frame, Widget& content,
std::size_t height, int column);
diff --git a/plugingui/testmain.cc b/plugingui/testmain.cc
index 07e5f8d..9d10bd9 100644
--- a/plugingui/testmain.cc
+++ b/plugingui/testmain.cc
@@ -49,7 +49,7 @@ int main()
main_window.show();
// TODO: automatically use drumgizmo_plugin.h size here
- parent.resize(750, 466);
+ parent.resize(750, 613);
while(true)
{
diff --git a/plugingui/timingframecontent.cc b/plugingui/timingframecontent.cc
new file mode 100644
index 0000000..fef4d33
--- /dev/null
+++ b/plugingui/timingframecontent.cc
@@ -0,0 +1,131 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * timingframecontent.cc
+ *
+ * Sat Oct 14 19:39:33 CEST 2017
+ * Copyright 2017 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "timingframecontent.h"
+
+#include <cmath>
+
+#include <settings.h>
+
+#include "painter.h"
+
+namespace GUI
+{
+
+TimingframeContent::TimingframeContent(Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier)
+ : Widget(parent)
+ , settings(settings)
+ , settings_notifier(settings_notifier)
+{
+ layout.setResizeChildren(false);
+
+ tightness.resize(80, 80);
+ tightness_knob.resize(30, 30);
+ tightness_knob.showValue(false);
+ tightness.setControl(&tightness_knob);
+ layout.addItem(&tightness);
+
+ regain.resize(80, 80);
+ regain_knob.resize(30, 30);
+ regain_knob.showValue(false);
+ regain.setControl(&regain_knob);
+ layout.addItem(&regain);
+
+ laidback.resize(80, 80);
+ laidback_knob.resize(30, 30);
+ laidback_knob.showValue(false);
+ laidback.setControl(&laidback_knob);
+ layout.addItem(&laidback);
+ // set range to [-1, 1]
+ laidback.offset = -1.0f;
+ laidback.scale = 2.0f;
+
+ layout.setPosition(&tightness, GridLayout::GridRange{0, 1, 0, 1});
+ layout.setPosition(&regain, GridLayout::GridRange{1, 2, 0, 1});
+ layout.setPosition(&laidback, GridLayout::GridRange{2, 3, 0, 1});
+
+ CONNECT(this, settings_notifier.latency_stddev,
+ this, &TimingframeContent::tightnessSettingsValueChanged);
+ CONNECT(this, settings_notifier.latency_regain,
+ this, &TimingframeContent::regainSettingsValueChanged);
+ CONNECT(this, settings_notifier.latency_laid_back,
+ this, &TimingframeContent::laidbackSettingsValueChanged);
+
+ CONNECT(&tightness_knob, valueChangedNotifier,
+ this, &TimingframeContent::tightnessKnobValueChanged);
+ CONNECT(&regain_knob, valueChangedNotifier,
+ this, &TimingframeContent::regainKnobValueChanged);
+ CONNECT(&laidback_knob, valueChangedNotifier,
+ this, &TimingframeContent::laidbackKnobValueChanged);
+
+}
+
+void TimingframeContent::tightnessKnobValueChanged(float value)
+{
+ value -= 1.0f;
+ value *= -1.0f;
+ value *= 500.0f;
+ settings.latency_stddev.store(value);
+}
+
+void TimingframeContent::tightnessSettingsValueChanged(float value)
+{
+ value /= 500.0f;
+ value *= -1.0f;
+ value += 1.0f;
+ tightness_knob.setValue(value);
+}
+
+void TimingframeContent::regainKnobValueChanged(float value)
+{
+ settings.latency_regain.store(value);
+}
+
+void TimingframeContent::regainSettingsValueChanged(float value)
+{
+ regain_knob.setValue(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));
+}
+
+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);
+}
+
+} // GUI::
diff --git a/plugingui/timingframecontent.h b/plugingui/timingframecontent.h
new file mode 100644
index 0000000..78fe5d6
--- /dev/null
+++ b/plugingui/timingframecontent.h
@@ -0,0 +1,75 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * timingframecontent.h
+ *
+ * Sat Oct 14 19:39:33 CEST 2017
+ * Copyright 2017 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of DrumGizmo.
+ *
+ * DrumGizmo is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DrumGizmo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with DrumGizmo; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#pragma once
+
+#include "knob.h"
+#include "label.h"
+#include "layout.h"
+#include "widget.h"
+
+#include "humanizerframecontent.h" // For LabeledControl
+
+#include <iomanip>
+#include <sstream>
+
+struct Settings;
+class SettingsNotifier;
+
+namespace GUI
+{
+
+class TimingframeContent
+ : public Widget
+{
+public:
+ TimingframeContent(Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier);
+
+private:
+ void tightnessKnobValueChanged(float value);
+ void tightnessSettingsValueChanged(float value);
+ void regainKnobValueChanged(float value);
+ void regainSettingsValueChanged(float value);
+ void laidbackKnobValueChanged(float value);
+ void laidbackSettingsValueChanged(int value);
+
+ GridLayout layout{this, 3, 1};
+
+ LabeledControl tightness{this, "Tightness"};
+ LabeledControl regain{this, "Timing Regain"};
+ LabeledControl laidback{this, "Laid Back-ness"};
+
+ Knob tightness_knob{&tightness};
+ Knob regain_knob{&regain};
+ Knob laidback_knob{&laidback};
+
+ Settings& settings;
+ SettingsNotifier& settings_notifier;
+};
+
+} // GUI::