summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-07-15 20:35:52 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-07-15 20:41:10 +0200
commita0484778a9953dfd1948bf4dac71c51deab18cab (patch)
tree15b9ff0c0b745b0efb02375d285ade09bbdf0f18 /plugingui
parent34578fdef6a9f77aa285501130be55fcd560c03d (diff)
Revorked visualiser UI and a few more parameter tweaks.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/Makefile.am6
-rw-r--r--plugingui/humaniservisualiser.cc150
-rw-r--r--plugingui/humaniservisualiser.h58
-rw-r--r--plugingui/humanizerframecontent.h4
-rw-r--r--plugingui/maintab.cc12
-rw-r--r--plugingui/maintab.h3
-rw-r--r--plugingui/resources/stddev_horizontal.pngbin0 -> 271 bytes
-rw-r--r--plugingui/resources/stddev_horizontal_disabled.pngbin0 -> 273 bytes
-rw-r--r--plugingui/resources/stddev_vertical.pngbin0 -> 277 bytes
-rw-r--r--plugingui/resources/stddev_vertical_disabled.pngbin0 -> 277 bytes
-rw-r--r--plugingui/timingframecontent.cc10
-rw-r--r--plugingui/timingframecontent.h2
-rw-r--r--plugingui/visualizerframecontent.cc51
-rw-r--r--plugingui/visualizerframecontent.h56
14 files changed, 285 insertions, 67 deletions
diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am
index fc31f35..84b351f 100644
--- a/plugingui/Makefile.am
+++ b/plugingui/Makefile.am
@@ -14,6 +14,10 @@ RES = \
resources/pushbutton.png \
resources/sidebar.png \
resources/slider.png \
+ resources/stddev_horizontal.png \
+ resources/stddev_horizontal_disabled.png \
+ resources/stddev_vertical.png \
+ resources/stddev_vertical_disabled.png \
resources/switch_back_off.png \
resources/switch_back_on.png \
resources/switch_front.png \
@@ -102,6 +106,7 @@ nodist_libdggui_la_SOURCES = \
toggle.cc \
utf8.cc \
verticalline.cc \
+ visualizerframecontent.cc \
widget.cc \
window.cc \
lodepng/lodepng.cpp
@@ -231,6 +236,7 @@ EXTRA_DIST = \
toggle.h \
utf8.h \
verticalline.h \
+ visualizerframecontent.h \
widget.h \
window.h \
lodepng/lodepng.h
diff --git a/plugingui/humaniservisualiser.cc b/plugingui/humaniservisualiser.cc
index 5b5abb7..a823c64 100644
--- a/plugingui/humaniservisualiser.cc
+++ b/plugingui/humaniservisualiser.cc
@@ -31,96 +31,168 @@
#include <notifier.h>
#include <settings.h>
-#include <iostream>
+#include <hugin.hpp>
HumaniserVisualiser::HumaniserVisualiser(GUI::Widget* parent,
+ Settings& settings,
SettingsNotifier& settings_notifier)
: GUI::Widget(parent)
+ , canvas(this, settings, settings_notifier)
+{
+ canvas.move(7, 7);
+}
+
+void HumaniserVisualiser::repaintEvent(GUI::RepaintEvent *repaintEvent)
+{
+ GUI::Painter p(*this);
+
+ box.setSize(width(), height());
+ p.drawImage(0, 0, box);
+}
+
+void HumaniserVisualiser::resize(std::size_t width, std::size_t height)
+{
+ Widget::resize(width, height);
+ if(width < 14 || height < 14)
+ {
+ canvas.resize(1, 1);
+ return;
+ }
+ canvas.resize(width - 14, height - 14);
+}
+
+HumaniserVisualiser::Canvas::Canvas(GUI::Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier)
+ : GUI::Widget(parent)
, settings_notifier(settings_notifier)
+ , latency_max_samples(settings.latency_max.load() *
+ settings.samplerate.load() / 1000)
{
+ CONNECT(this, settings_notifier.enable_latency_modifier,
+ this, &HumaniserVisualiser::Canvas::latencyEnabledChanged);
+ CONNECT(this, settings_notifier.enable_velocity_modifier,
+ this, &HumaniserVisualiser::Canvas::velocityEnabledChanged);
+
CONNECT(this, settings_notifier.latency_current,
- this, &HumaniserVisualiser::latencyOffsetChanged);
+ this, &HumaniserVisualiser::Canvas::latencyOffsetChanged);
CONNECT(this, settings_notifier.velocity_modifier_current,
- this, &HumaniserVisualiser::velocityOffsetChanged);
+ this, &HumaniserVisualiser::Canvas::velocityOffsetChanged);
CONNECT(this, settings_notifier.latency_stddev,
- this, &HumaniserVisualiser::latencyStddevChanged);
+ this, &HumaniserVisualiser::Canvas::latencyStddevChanged);
CONNECT(this, settings_notifier.latency_laid_back,
- this, &HumaniserVisualiser::latencyLaidbackChanged);
+ this, &HumaniserVisualiser::Canvas::latencyLaidbackChanged);
CONNECT(this, settings_notifier.velocity_stddev,
- this, &HumaniserVisualiser::velocityStddevChanged);
+ this, &HumaniserVisualiser::Canvas::velocityStddevChanged);
}
-void HumaniserVisualiser::repaintEvent(GUI::RepaintEvent *repaintEvent)
+void HumaniserVisualiser::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent)
{
+ if(width() < 1 || height() < 1)
+ {
+ return;
+ }
+
GUI::Painter p(*this);
- // Background
- p.setColour(GUI::Colour(0, 0, 1));
- p.drawFilledRectangle(0, 0, width(), height());
+ p.clear();
+
+ const int spx = latency_max_samples * 2 / width(); // samples pr. pixel
+
+ int x = latency_offset / spx + width() / 2;
+ float v = (-1.0f * velocity_offset + 1.0f) * 0.8;
+ int y = height() * 0.2 + v * height();
+ y = std::max(0, y);
+ int w = latency_stddev / spx * 3 * 2; // stddev is ~ +/- 3 span
+ int h = velocity_stddev * height() / 4;
- int x = latency_offset / 2000.0 * width() / 2 + width() / 2;
- int y = velocity_offset * height();
- int w = latency_stddev / 10;
- int h = velocity_stddev * 20;
+ DEBUG(vis, "max: %d, spx: %d, x: %d, w: %d", latency_max_samples, spx, x, w);
// Stddev squares
- float v = w;
- while(v > 1)
+ if(latency_enabled)
{
- float a = 1.0f - v / (float)w;
- a = a * a * a;
- p.setColour(GUI::Colour(1.0f, 0.0f, 1.0f, a));
- p.drawFilledRectangle(x - v / 2, 0,
- x + v / 2 + 1, height());
- v -= 1.0f;
+ p.drawImageStretched(x - w / 2, 0, stddev_h, w, height());
+ }
+ else
+ {
+ p.drawImageStretched(x - w / 2, 0, stddev_h_disabled, w, height());
}
- v = h;
- while(v > 1)
+ if(velocity_enabled)
+ {
+ p.drawImageStretched(0, y - h / 2, stddev_v, width(), h);
+ }
+ else
{
- float a = 1.0f - v / (float)h;
- a = a * a * a;
- p.setColour(GUI::Colour(1.0f, 0.0f, 1.0f, a));
- p.drawFilledRectangle(0, y - v / 2,
- width(), y + v / 2 + 1);
- v -= 1.0f;
+ p.drawImageStretched(0, y - h / 2, stddev_v_disabled, width(), h);
}
// Lines
- p.setColour(GUI::Colour(0, 1, 1));
+ if(velocity_enabled)
+ {
+ p.setColour(GUI::Colour(0.0f, 1.0f, 1.0f));
+ }
+ else
+ {
+ p.setColour(GUI::Colour(0.4f, 0.4f, 0.4f));
+ }
p.drawLine(0, y, width(), y);
+
+ if(latency_enabled)
+ {
+ p.setColour(GUI::Colour(0.0f, 1.0f, 1.0f));
+ }
+ else
+ {
+ p.setColour(GUI::Colour(0.4f, 0.4f, 0.4f));
+ }
p.drawLine(x, 0, x, height());
+
+ // Zero-lines
+ p.setColour(GUI::Colour(0.0f, 1.0f, 0.0f, 0.9f));
+ p.drawLine(0, height() * 0.2f, width(), height() * 0.2f);
+ p.drawLine(width() / 2, 0, width() / 2, height());
+}
+
+void HumaniserVisualiser::Canvas::latencyEnabledChanged(bool enabled)
+{
+ latency_enabled = enabled;
+ redraw();
+}
+
+void HumaniserVisualiser::Canvas::velocityEnabledChanged(bool enabled)
+{
+ velocity_enabled = enabled;
+ redraw();
}
-void HumaniserVisualiser::latencyOffsetChanged(int offset)
+void HumaniserVisualiser::Canvas::latencyOffsetChanged(int offset)
{
latency_offset = offset;
redraw();
}
-void HumaniserVisualiser::velocityOffsetChanged(float offset)
+void HumaniserVisualiser::Canvas::velocityOffsetChanged(float offset)
{
- std::cout << "velocity_offset: " << offset << std::endl;
- velocity_offset = -1.0f * offset + 1.0f;
+ velocity_offset = offset;
redraw();
}
-void HumaniserVisualiser::latencyStddevChanged(float stddev)
+void HumaniserVisualiser::Canvas::latencyStddevChanged(float stddev)
{
latency_stddev = stddev;
redraw();
}
-void HumaniserVisualiser::latencyLaidbackChanged(int laidback)
+void HumaniserVisualiser::Canvas::latencyLaidbackChanged(int laidback)
{
this->laidback = laidback;
redraw();
}
-void HumaniserVisualiser::velocityStddevChanged(float stddev)
+void HumaniserVisualiser::Canvas::velocityStddevChanged(float stddev)
{
- std::cout << "velocity_stddev: " << stddev << std::endl;
velocity_stddev = stddev;
redraw();
}
diff --git a/plugingui/humaniservisualiser.h b/plugingui/humaniservisualiser.h
index f7f4c15..6ef39b9 100644
--- a/plugingui/humaniservisualiser.h
+++ b/plugingui/humaniservisualiser.h
@@ -27,7 +27,10 @@
#pragma once
#include "widget.h"
+#include "texturedbox.h"
+#include "texture.h"
+struct Settings;
class SettingsNotifier;
class HumaniserVisualiser
@@ -35,22 +38,53 @@ class HumaniserVisualiser
{
public:
HumaniserVisualiser(GUI::Widget* parent,
+ Settings& settings,
SettingsNotifier& settings_notifier);
// From Widget:
virtual void repaintEvent(GUI::RepaintEvent *repaintEvent) override;
-
- void latencyOffsetChanged(int offset);
- void velocityOffsetChanged(float offset);
- void latencyStddevChanged(float stddev);
- void latencyLaidbackChanged(int laidback);
- void velocityStddevChanged(float stddev);
+ virtual void resize(std::size_t width, std::size_t height) override;
private:
- int latency_offset;
- float velocity_offset;
- float latency_stddev;
- int laidback;
- float velocity_stddev;
- SettingsNotifier& settings_notifier;
+ GUI::TexturedBox box{getImageCache(), ":resources/widget.png",
+ 0, 0, // atlas offset (x, y)
+ 7, 1, 7, // dx1, dx2, dx3
+ 7, 63, 7}; // dy1, dy2, dy3
+
+ class Canvas
+ : public GUI::Widget
+ {
+ public:
+ Canvas(GUI::Widget* parent, Settings& settings,
+ SettingsNotifier& settings_notifier);
+
+ // From Widget:
+ virtual void repaintEvent(GUI::RepaintEvent *repaintEvent) override;
+
+ void latencyEnabledChanged(bool enabled);
+ void velocityEnabledChanged(bool enabled);
+ void latencyOffsetChanged(int offset);
+ void velocityOffsetChanged(float offset);
+ void latencyStddevChanged(float stddev);
+ void latencyLaidbackChanged(int laidback);
+ void velocityStddevChanged(float stddev);
+
+ GUI::Texture stddev_h{getImageCache(), ":resources/stddev_horizontal.png"};
+ GUI::Texture stddev_h_disabled{getImageCache(), ":resources/stddev_horizontal_disabled.png"};
+ GUI::Texture stddev_v{getImageCache(), ":resources/stddev_vertical.png"};
+ GUI::Texture stddev_v_disabled{getImageCache(), ":resources/stddev_vertical_disabled.png"};
+
+ bool latency_enabled{false};
+ bool velocity_enabled{false};
+
+ int latency_offset;
+ float velocity_offset;
+ float latency_stddev;
+ int laidback;
+ float velocity_stddev;
+ SettingsNotifier& settings_notifier;
+ const int latency_max_samples;
+ };
+
+ Canvas canvas;
};
diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h
index 2cf708d..4befae0 100644
--- a/plugingui/humanizerframecontent.h
+++ b/plugingui/humanizerframecontent.h
@@ -56,8 +56,8 @@ private:
GridLayout layout{this, 3, 1};
- LabeledControl attack{this, "Attack"};
- LabeledControl falloff{this, "Release"};
+ LabeledControl attack{this, "Attack"}; // drummer strength
+ LabeledControl falloff{this, "Release"}; // regain
LabeledControl stddev{this, "StdDev"};
Knob attack_knob{&attack};
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
index 170d937..3aae788 100644
--- a/plugingui/maintab.cc
+++ b/plugingui/maintab.cc
@@ -41,6 +41,7 @@ MainTab::MainTab(Widget* parent,
, bleedcontrolframe_content{this, settings, settings_notifier}
, resamplingframe_content{this, settings_notifier}
, timingframe_content{this, settings, settings_notifier}
+ , visualizerframe_content{this, settings, settings_notifier}
, settings(settings)
, settings_notifier(settings_notifier)
{
@@ -49,12 +50,13 @@ MainTab::MainTab(Widget* parent,
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("Resampling", resampling_frame, resamplingframe_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);
+ add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 10, 1);
+ add("Visualizer", visualizer_frame, visualizerframe_content, 10, 1);
+ add("Timing Humanizer", timing_frame, timingframe_content, 10, 1);
+ add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 9, 1);
+ add("Disk Streaming", diskstreaming_frame, diskstreamingframe_content, 10, 1);
humanizer_frame.setOnSwitch(settings.enable_velocity_modifier);
bleedcontrol_frame.setOnSwitch(settings.enable_bleed_control);
diff --git a/plugingui/maintab.h b/plugingui/maintab.h
index c52205b..efd83e9 100644
--- a/plugingui/maintab.h
+++ b/plugingui/maintab.h
@@ -36,6 +36,7 @@
#include "bleedcontrolframecontent.h"
#include "resamplingframecontent.h"
#include "timingframecontent.h"
+#include "visualizerframecontent.h"
struct Settings;
class SettingsNotifier;
@@ -73,6 +74,7 @@ private:
FrameWidget bleedcontrol_frame{this, true};
FrameWidget resampling_frame{this, true};
FrameWidget timing_frame{this, true};
+ FrameWidget visualizer_frame{this, false};
DrumkitframeContent drumkitframe_content;
StatusframeContent statusframe_content;
@@ -81,6 +83,7 @@ private:
BleedcontrolframeContent bleedcontrolframe_content;
ResamplingframeContent resamplingframe_content;
TimingframeContent timingframe_content;
+ VisualizerframeContent visualizerframe_content;
void add(std::string const& title, FrameWidget& frame, Widget& content,
std::size_t height, int column);
diff --git a/plugingui/resources/stddev_horizontal.png b/plugingui/resources/stddev_horizontal.png
new file mode 100644
index 0000000..efed3cf
--- /dev/null
+++ b/plugingui/resources/stddev_horizontal.png
Binary files differ
diff --git a/plugingui/resources/stddev_horizontal_disabled.png b/plugingui/resources/stddev_horizontal_disabled.png
new file mode 100644
index 0000000..12c4f2f
--- /dev/null
+++ b/plugingui/resources/stddev_horizontal_disabled.png
Binary files differ
diff --git a/plugingui/resources/stddev_vertical.png b/plugingui/resources/stddev_vertical.png
new file mode 100644
index 0000000..50dab80
--- /dev/null
+++ b/plugingui/resources/stddev_vertical.png
Binary files differ
diff --git a/plugingui/resources/stddev_vertical_disabled.png b/plugingui/resources/stddev_vertical_disabled.png
new file mode 100644
index 0000000..786f468
--- /dev/null
+++ b/plugingui/resources/stddev_vertical_disabled.png
Binary files differ
diff --git a/plugingui/timingframecontent.cc b/plugingui/timingframecontent.cc
index d6b4c29..d02f86f 100644
--- a/plugingui/timingframecontent.cc
+++ b/plugingui/timingframecontent.cc
@@ -40,7 +40,6 @@ TimingframeContent::TimingframeContent(Widget* parent,
: Widget(parent)
, settings(settings)
, settings_notifier(settings_notifier)
- , visualiser(this, settings_notifier)
{
layout.setResizeChildren(false);
@@ -72,9 +71,6 @@ TimingframeContent::TimingframeContent(Widget* parent,
layout.setPosition(&regain, GridLayout::GridRange{1, 2, 0, 1});
layout.setPosition(&laidback, GridLayout::GridRange{2, 3, 0, 1});
- visualiser.move(80, 40);
- visualiser.resize(40, 40);
-
CONNECT(this, settings_notifier.latency_stddev,
this, &TimingframeContent::tightnessSettingsValueChanged);
CONNECT(this, settings_notifier.latency_regain,
@@ -111,7 +107,7 @@ float TimingframeContent::tightnessSettingsToKnob(float value) const
float TimingframeContent::laidbackKnobToSettings(float value) const
{
value -= 0.5f;
- value *= 2.0f;
+ value *= 4.0f;
value *= settings.latency_max.load();
return std::lround(value);
@@ -121,8 +117,8 @@ float TimingframeContent::laidbackSettingsToKnob(int int_value) const
{
float value = int_value;
value /= (float)settings.latency_max.load();
- value *= 0.5;
- value += 0.5;
+ value /= 4.0f;
+ value += 0.5f;
return value;
}
diff --git a/plugingui/timingframecontent.h b/plugingui/timingframecontent.h
index e0131e3..a8ed62c 100644
--- a/plugingui/timingframecontent.h
+++ b/plugingui/timingframecontent.h
@@ -31,7 +31,6 @@
#include "labeledcontrol.h"
#include "layout.h"
#include "widget.h"
-#include "humaniservisualiser.h"
#include <settings.h>
@@ -79,7 +78,6 @@ private:
Settings& settings;
SettingsNotifier& settings_notifier;
- HumaniserVisualiser visualiser;
};
} // GUI::
diff --git a/plugingui/visualizerframecontent.cc b/plugingui/visualizerframecontent.cc
new file mode 100644
index 0000000..7e5b298
--- /dev/null
+++ b/plugingui/visualizerframecontent.cc
@@ -0,0 +1,51 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * visualizerframecontent.cc
+ *
+ * Tue Jul 10 20:52:22 CEST 2018
+ * Copyright 2018 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 "visualizerframecontent.h"
+
+#include <cmath>
+#include <iostream>
+
+#include "painter.h"
+
+namespace GUI
+{
+
+VisualizerframeContent::VisualizerframeContent(Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier)
+ : Widget(parent)
+ , visualizer(this, settings, settings_notifier)
+{
+}
+
+void VisualizerframeContent::resize(std::size_t width, std::size_t height)
+{
+ Widget::resize(width, height);
+ visualizer.resize(width, height);
+}
+
+} // GUI::
diff --git a/plugingui/visualizerframecontent.h b/plugingui/visualizerframecontent.h
new file mode 100644
index 0000000..edf8f35
--- /dev/null
+++ b/plugingui/visualizerframecontent.h
@@ -0,0 +1,56 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * visualizerframecontent.h
+ *
+ * Tue Jul 10 20:52:22 CEST 2018
+ * Copyright 2018 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 "layout.h"
+#include "widget.h"
+#include "humaniservisualiser.h"
+
+#include <settings.h>
+
+#include <iomanip>
+#include <sstream>
+
+class SettingsNotifier;
+
+namespace GUI
+{
+
+class VisualizerframeContent
+ : public Widget
+{
+public:
+ VisualizerframeContent(Widget* parent, Settings& settings,
+ SettingsNotifier& settings_notifier);
+
+ // From Widget
+ virtual void resize(std::size_t width, std::size_t height) override;
+
+private:
+ HumaniserVisualiser visualizer;
+};
+
+} // GUI::