summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorTheMarlboroMan <marlborometal@gmail.com>2020-11-15 16:50:27 +0100
committerTheMarlboroMan <marlborometal@gmail.com>2020-11-15 17:04:21 +0100
commiteb0a72576c71557c8bb64cfd319620f5ea7ba24c (patch)
treedf15c068870705d7c7847b8d98a760e058756f03 /plugingui
parentb0fa70c97c9b4886fb6e063664dc4d10daf12c1c (diff)
Implementation of the voice limiting feature.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/Makefile.am2
-rw-r--r--plugingui/Makefile.mingw321
-rw-r--r--plugingui/labeledcontrol.h19
-rw-r--r--plugingui/maintab.cc52
-rw-r--r--plugingui/maintab.h6
-rw-r--r--plugingui/voicelimitframecontent.cc123
-rw-r--r--plugingui/voicelimitframecontent.h73
7 files changed, 263 insertions, 13 deletions
diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am
index 65e7011..d102024 100644
--- a/plugingui/Makefile.am
+++ b/plugingui/Makefile.am
@@ -154,6 +154,7 @@ GUI_SRC = \
utf8.cc \
verticalline.cc \
visualizerframecontent.cc \
+ voicelimitframecontent.cc \
widget.cc \
window.cc
@@ -227,6 +228,7 @@ GUI_HDR = \
utf8.h \
verticalline.h \
visualizerframecontent.h \
+ voicelimitframecontent.h \
widget.h \
window.h
diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32
index df735d5..bc58c11 100644
--- a/plugingui/Makefile.mingw32
+++ b/plugingui/Makefile.mingw32
@@ -56,6 +56,7 @@ GUI_SRC = \
verticalline.cc \
resource.cc \
resource_data.cc \
+ voicelimitframecontent.cc \
lodepng/lodepng.cpp
GUI_CFLAGS=-DUSE_THREAD -DUI_WIN32 -DSTANDALONE
diff --git a/plugingui/labeledcontrol.h b/plugingui/labeledcontrol.h
index cf01b46..3cbae39 100644
--- a/plugingui/labeledcontrol.h
+++ b/plugingui/labeledcontrol.h
@@ -31,6 +31,7 @@
#include <iomanip>
#include <sstream>
+#include <functional>
namespace GUI
{
@@ -39,6 +40,10 @@ class LabeledControl
: public Widget
{
public:
+
+ using ValueTransformationFunction =
+ std::function<std::string(float, float, float)>;
+
LabeledControl(Widget* parent, const std::string& name)
: Widget(parent)
{
@@ -63,6 +68,11 @@ public:
layout.addItem(&value);
}
+ void setValueTransformationFunction(ValueTransformationFunction function)
+ {
+ value_transformation_func = function;
+ }
+
float offset{0.0f};
float scale{1.0f};
@@ -71,8 +81,17 @@ private:
Label caption{this};
Label value{this};
+ ValueTransformationFunction value_transformation_func;
+
void setValue(float new_value)
{
+ if(value_transformation_func)
+ {
+ value.setText(value_transformation_func(new_value, scale, offset));
+ return;
+ }
+
+ //TODO: Surely this could be the "default transformation function"?
new_value *= scale;
new_value += offset;
std::stringstream stream;
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
index 05c5e6f..d6da057 100644
--- a/plugingui/maintab.cc
+++ b/plugingui/maintab.cc
@@ -46,6 +46,7 @@ MainTab::MainTab(Widget* parent,
, sampleselectionframe_content{this, settings, settings_notifier}
, visualizerframe_content{this, settings, settings_notifier}
, powerframe_content{this, settings, settings_notifier}
+ , voicelimit_content{this, settings, settings_notifier}
, settings(settings)
, settings_notifier(settings_notifier)
{
@@ -116,30 +117,50 @@ MainTab::MainTab(Widget* parent,
_("the lower left corner, then the three control points, and then\n") +
_("the upper right corner, enabling to draw more complicated functions.");
- layout.setResizeChildren(true);
+ const std::string voice_limit_tip = std::string(
+ _("This feature controls how many voices can simultaneously be in play for a given\n")) +
+ _("instrument. When this feature is active, Drumgizmo will silence any excess \n") +
+ _("voices to ease the burden of processing.\n") +
+ _("\n") +
+ _("This feature works on a per-instrument basis, e.g., voices played on the bass\n") +
+ _("drum can only be silenced by other bass drum hits, and not by the snare.\n") +
+ _("\n") +
+ _(" * Max voices: The maximum number of voices that should be allowed to play.\n") +
+ _(" * Rampdown time: How many seconds it takes to silence a voice.");
- add(_("Drumkit"), drumkit_frame, drumkitframe_content, 12, 0);
- add(_("Status"), status_frame, statusframe_content, 14, 0);
- add(_("Resampling"), resampling_frame, resamplingframe_content, 9, 0);
- add(_("Disk Streaming"), diskstreaming_frame, diskstreamingframe_content, 7, 0);
- add(_("Bleed Control"), bleedcontrol_frame, bleedcontrolframe_content, 7, 0);
+ layout.setResizeChildren(true);
- add(_("Velocity Humanizer"), humanizer_frame, humanizerframe_content, 8, 1);
+ //Left column...
+ add(_("Drumkit"), drumkit_frame, drumkitframe_content, 14, 0);
+ add(_("Status"), status_frame, statusframe_content, 12, 0);
+ add(_("Resampling"), resampling_frame, resamplingframe_content, 10, 0);
+ add(_("Voice Limit"), voicelimit_frame, voicelimit_content, 10, 0);
+ voicelimit_frame.setHelpText(voice_limit_tip);
+ add(_("Disk Streaming"), diskstreaming_frame, diskstreamingframe_content, 9, 0);
+ add(_("Bleed Control"), bleedcontrol_frame, bleedcontrolframe_content, 9, 0);
+
+ //Right column
+ add(_("Velocity Humanizer"), humanizer_frame, humanizerframe_content,10, 1);
humanizer_frame.setHelpText(humanizer_tip);
- add(_("Timing Humanizer"), timing_frame, timingframe_content, 8, 1);
+
+ add(_("Timing Humanizer"), timing_frame, timingframe_content, 10, 1);
timing_frame.setHelpText(timing_tip);
+
add(_("Sample Selection"), sampleselection_frame,
- sampleselectionframe_content, 8, 1);
+ sampleselectionframe_content, 10, 1);
sampleselection_frame.setHelpText(sampleselection_tip);
- add(_("Visualizer"), visualizer_frame, visualizerframe_content, 8, 1);
+
+ add(_("Visualizer"), visualizer_frame, visualizerframe_content, 14, 1);
visualizer_frame.setHelpText(visualizer_tip);
- add(_("Velocity Curve"), power_frame, powerframe_content, 17, 1);
+
+ add(_("Velocity Curve"), power_frame, powerframe_content, 20, 1);
power_frame.setHelpText(power_tip);
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);
+ voicelimit_frame.setOnSwitch(settings.enable_voice_limit);
// FIXME:
bleedcontrol_frame.setEnabled(false);
@@ -160,11 +181,13 @@ MainTab::MainTab(Widget* parent,
this, &MainTab::timingOnChange);
CONNECT(&bleedcontrol_frame, onEnabledChanged,
&bleedcontrolframe_content, &BleedcontrolframeContent::setEnabled);
-
CONNECT(&settings_notifier, enable_powermap,
&power_frame, &FrameWidget::setOnSwitch);
CONNECT(&power_frame, onSwitchChangeNotifier,
this, &MainTab::powerOnChange);
+ CONNECT(&voicelimit_frame, onSwitchChangeNotifier,
+ this, &MainTab::voicelimitOnChange);
+
}
void MainTab::resize(std::size_t width, std::size_t height)
@@ -202,6 +225,11 @@ void MainTab::powerOnChange(bool on)
settings.enable_powermap.store(on);
}
+void MainTab::voicelimitOnChange(bool status)
+{
+ settings.enable_voice_limit.store(status);
+}
+
void MainTab::add(std::string const& title, FrameWidget& frame, Widget& content,
std::size_t height, int column)
{
diff --git a/plugingui/maintab.h b/plugingui/maintab.h
index a19b183..57aec72 100644
--- a/plugingui/maintab.h
+++ b/plugingui/maintab.h
@@ -39,6 +39,7 @@
#include "sampleselectionframecontent.h"
#include "visualizerframecontent.h"
#include "powerwidget.h"
+#include "voicelimitframecontent.h"
struct Settings;
class SettingsNotifier;
@@ -65,10 +66,11 @@ private:
void resamplingOnChange(bool on);
void timingOnChange(bool on);
void powerOnChange(bool on);
+ void voicelimitOnChange(bool status);
Image logo{":resources/logo.png"};
- GridLayout layout{this, 2, 49};
+ GridLayout layout{this, 2, 64};
FrameWidget drumkit_frame{this, false};
FrameWidget status_frame{this, false};
@@ -80,6 +82,7 @@ private:
FrameWidget sampleselection_frame{this, false, true};
FrameWidget visualizer_frame{this, false, true};
FrameWidget power_frame{this, true, true};
+ FrameWidget voicelimit_frame{this, true, true};
DrumkitframeContent drumkitframe_content;
StatusframeContent statusframe_content;
@@ -91,6 +94,7 @@ private:
SampleselectionframeContent sampleselectionframe_content;
VisualizerframeContent visualizerframe_content;
PowerWidget powerframe_content;
+ VoiceLimitFrameContent voicelimit_content;
void add(std::string const& title, FrameWidget& frame, Widget& content,
std::size_t height, int column);
diff --git a/plugingui/voicelimitframecontent.cc b/plugingui/voicelimitframecontent.cc
new file mode 100644
index 0000000..c7c8c28
--- /dev/null
+++ b/plugingui/voicelimitframecontent.cc
@@ -0,0 +1,123 @@
+/***************************************************************************
+ * voicelimitframecontent.cc
+ *
+ * Wed Aug 26 14:53:03 CEST 2020
+ * Copyright 2020 The Marlboro Man
+ * marlborometal@gmail.com
+ ****************************************************************************/
+
+/*
+ * 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 "voicelimitframecontent.h"
+
+#include <settings.h>
+
+namespace GUI
+{
+
+VoiceLimitFrameContent::VoiceLimitFrameContent(Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier)
+ : Widget(parent)
+ , settings(settings)
+ , settings_notifier(settings_notifier)
+{
+ //Setup frame.
+ label_text.setText(_("Per-instrument voice limit:"));
+ label_text.setAlignment(TextAlignment::center);
+
+ //Setup layout
+ layout.setResizeChildren(false);
+
+ auto setup_control =
+ [](Knob& knob,
+ LabeledControl& label,
+ GridLayout& layout,
+ const GridLayout::GridRange& gridrange,
+ float min,
+ float max,
+ float defaultval)
+ {
+ knob.resize(30, 30);
+ knob.showValue(false);
+ knob.setDefaultValue(defaultval);
+ knob.setRange(min, max);
+ label.resize(80, 80);
+ label.setControl(&knob);
+ layout.addItem(&label);
+ layout.setPosition(&label, gridrange);
+ };
+
+ setup_control(knob_max_voices, lc_max_voices, layout, {0, 1, 0, 1},
+ 1.0f, 30.0f, Settings::voice_limit_max_default);
+
+ setup_control(knob_rampdown_time, lc_rampdown_time, layout, {1, 2, 0, 1},
+ 0.01f, 2.0f, Settings::voice_limit_rampdown_default);
+
+
+ auto voices_transform =
+ [this](double new_value, double scale, double offset) -> std::string
+ {
+ new_value *= scale;
+ new_value += offset;
+ return std::to_string(convertMaxVoices(new_value));
+ };
+
+ lc_max_voices.setValueTransformationFunction(voices_transform);
+
+ //GUI to settings.
+ CONNECT(&knob_max_voices, valueChangedNotifier,
+ this, &VoiceLimitFrameContent::maxvoicesKnobValueChanged);
+
+ CONNECT(&knob_rampdown_time, valueChangedNotifier,
+ this, &VoiceLimitFrameContent::rampdownKnobValueChanged);
+
+ //Settings to GUI
+ CONNECT(this, settings_notifier.voice_limit_max,
+ this, &VoiceLimitFrameContent::maxvoicesSettingsValueChanged);
+
+ CONNECT(this, settings_notifier.voice_limit_rampdown,
+ this, &VoiceLimitFrameContent::rampdownSettingsValueChanged);
+}
+
+void VoiceLimitFrameContent::maxvoicesKnobValueChanged(float value)
+{
+ settings.voice_limit_max.store((int)value);
+}
+
+void VoiceLimitFrameContent::rampdownKnobValueChanged(float value)
+{
+ settings.voice_limit_rampdown.store(value);
+}
+
+void VoiceLimitFrameContent::maxvoicesSettingsValueChanged(float value)
+{
+ knob_max_voices.setValue(convertMaxVoices(value));
+}
+
+void VoiceLimitFrameContent::rampdownSettingsValueChanged(float value)
+{
+ knob_rampdown_time.setValue(value);
+}
+
+std::size_t VoiceLimitFrameContent::convertMaxVoices(float value)
+{
+ return static_cast<std::size_t>(value);
+}
+
+}
diff --git a/plugingui/voicelimitframecontent.h b/plugingui/voicelimitframecontent.h
new file mode 100644
index 0000000..8b08014
--- /dev/null
+++ b/plugingui/voicelimitframecontent.h
@@ -0,0 +1,73 @@
+/* -*- Mode: c++ -*- */
+/***************************************************************************
+ * voicelimitframecontent.h
+ *
+ * Wed Aug 26 14:53:03 CEST 2020
+ * Copyright 2020 The Marlboro Man
+ * marlborometal@gmail.com
+ ****************************************************************************/
+
+/*
+ * 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 <translation.h>
+
+#include "label.h"
+#include "knob.h"
+#include "labeledcontrol.h"
+#include "widget.h"
+
+struct Settings;
+class SettingsNotifier;
+
+namespace GUI
+{
+
+class VoiceLimitFrameContent
+ : public Widget
+{
+public:
+ VoiceLimitFrameContent(Widget* parent,
+ Settings& settings,
+ SettingsNotifier& settings_notifier);
+
+private:
+ void maxvoicesKnobValueChanged(float value);
+ void rampdownKnobValueChanged(float value);
+
+ void maxvoicesSettingsValueChanged(float value);
+ void rampdownSettingsValueChanged(float value);
+
+ std::size_t convertMaxVoices(float value);
+
+ Settings& settings;
+ SettingsNotifier& settings_notifier;
+
+ Label label_text{this};
+
+ GridLayout layout{this, 2, 1};
+
+ LabeledControl lc_max_voices{this, _("Max voices")};
+ LabeledControl lc_rampdown_time{this, _("Rampdown time")};
+
+ Knob knob_max_voices{&lc_max_voices};
+ Knob knob_rampdown_time{&lc_rampdown_time};
+};
+
+} // GUI::