Skip to content

Commit 151cf7a

Browse files
committed
horizontal menus for LPF and HPF
- Add support for displaying Selection-instances in horizontal menus, in order to display current filter mode. This uses regular font size to fit in 4 character names. - Move renderInHorizontalMenu() from patched_param::Integer to Number, where it works for both patched and unpatched parameters. - Refactor the colummn label code to MenuItem::renderColumnLabel(), fixing a bug in the chop-to-width logic while at it. - Refactor classes used for filter params to be more generic, so we don't need so many of them. - Fix a bug in horizontal menu rendering when there's only one relevant item, which isn't the first item. - Filter modes get short names: 12DB, 24DB, BP, DRV, NTCH, BP - Re-order the filter menu so mode is last, which works better in the horizontal menu -- and arguably in the vertical as well, even if there's now a slight ordering mismatch betweeh shortcuts and the menu. - Morph column is titled by the morph name for the filter family. - Turning filter mode to NONE makes all other filter menu items non-relevant. - Rename the NONE filter mode to OFF, which seems clearer in the menu.
1 parent e2e8a56 commit 151cf7a

29 files changed

+491
-302
lines changed

src/deluge/gui/l10n/english.json

+5
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,16 @@
220220
"STRING_FOR_ANALOG": "Analog",
221221

222222
"STRING_FOR_DRIVE": "Drive",
223+
"STRING_FOR_DRIVE_SHORT": "DRV",
223224
"STRING_FOR_SVF_BAND": "SVF Bandpass",
225+
"STRING_FOR_SVF_BAND_SHORT": "BP",
224226
"STRING_FOR_SVF_NOTCH": "SVF Notch",
227+
"STRING_FOR_SVF_NOTCH_SHORT": "NTCH",
225228
"STRING_FOR_HPLADDER": "HP Ladder",
226229
"STRING_FOR_12DB_LADDER": "12dB Ladder",
230+
"STRING_FOR_12DB_LADDER_SHORT": "12dB",
227231
"STRING_FOR_24DB_LADDER": "24dB Ladder",
232+
"STRING_FOR_24DB_LADDER_SHORT": "24dB",
228233
"STRING_FOR_FAST": "Fast",
229234
"STRING_FOR_SLOW": "Slow",
230235
"STRING_FOR_V_TRIGGER": "V-trig",

src/deluge/gui/l10n/g_english.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,16 @@ PLACE_SDRAM_DATA Language english{
188188
{STRING_FOR_DIGITAL, "Digital"},
189189
{STRING_FOR_ANALOG, "Analog"},
190190
{STRING_FOR_DRIVE, "Drive"},
191+
{STRING_FOR_DRIVE_SHORT, "DRV"},
191192
{STRING_FOR_SVF_BAND, "SVF Bandpass"},
193+
{STRING_FOR_SVF_BAND_SHORT, "BP"},
192194
{STRING_FOR_SVF_NOTCH, "SVF Notch"},
195+
{STRING_FOR_SVF_NOTCH_SHORT, "NTCH"},
193196
{STRING_FOR_HPLADDER, "HP Ladder"},
194197
{STRING_FOR_12DB_LADDER, "12dB Ladder"},
198+
{STRING_FOR_12DB_LADDER_SHORT, "12dB"},
195199
{STRING_FOR_24DB_LADDER, "24dB Ladder"},
200+
{STRING_FOR_24DB_LADDER_SHORT, "24dB"},
196201
{STRING_FOR_FAST, "Fast"},
197202
{STRING_FOR_SLOW, "Slow"},
198203
{STRING_FOR_V_TRIGGER, "V-trig"},

src/deluge/gui/l10n/strings.h

+5
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,16 @@ enum class String : size_t {
186186

187187
// gui/menu_item/filter/lpf_mode.h
188188
STRING_FOR_DRIVE,
189+
STRING_FOR_DRIVE_SHORT,
189190
STRING_FOR_HPLADDER,
190191
STRING_FOR_12DB_LADDER,
192+
STRING_FOR_12DB_LADDER_SHORT,
191193
STRING_FOR_24DB_LADDER,
194+
STRING_FOR_24DB_LADDER_SHORT,
192195
STRING_FOR_SVF_BAND,
196+
STRING_FOR_SVF_BAND_SHORT,
193197
STRING_FOR_SVF_NOTCH,
198+
STRING_FOR_SVF_NOTCH_SHORT,
194199

195200
// gui/menu_item/flash/status.h
196201
STRING_FOR_FAST,

src/deluge/gui/menu_item/enumeration.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ void Enumeration::selectEncoderAction(int32_t offset) {
2828
nextValue = std::clamp<int32_t>(nextValue, 0, numOptions - 1);
2929
}
3030

31-
D_PRINTLN("value = %d", nextValue);
32-
3331
setValue(nextValue);
3432

3533
// reset offset to account for wrapping

src/deluge/gui/menu_item/enumeration.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ class Enumeration : public Value<int32_t> {
1212
void beginSession(MenuItem* navigatedBackwardFrom) override;
1313
void selectEncoderAction(int32_t offset) override;
1414
virtual size_t size() = 0;
15-
/// @brief Should this menu wrap around? Destined to be virtualized and moved higher
16-
/// in the class hierarchy.
17-
bool wrapAround();
15+
/// @brief Should this menu wrap around?
16+
virtual bool wrapAround();
1817

1918
protected:
2019
void drawPixelsForOled() override = 0;

src/deluge/gui/menu_item/filter/hpf_freq.h

-39
This file was deleted.

src/deluge/gui/menu_item/filter/hpf_mode.h

-46
This file was deleted.
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2014-2023 Synthstrom Audible Limited
3+
*
4+
* This file is part of The Synthstrom Audible Deluge Firmware.
5+
*
6+
* The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7+
* terms of the GNU General Public License as published by the Free Software Foundation,
8+
* either version 3 of the License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
* See the GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with this program.
15+
* If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
#pragma once
18+
19+
#include "gui/ui/sound_editor.h"
20+
#include "model/mod_controllable/filters/filter_config.h"
21+
#include "modulation/patch/patch_cable_set.h"
22+
23+
namespace deluge::gui::menu_item::filter {
24+
25+
enum class FilterSlot : uint8_t {
26+
LPF,
27+
HPF,
28+
};
29+
30+
enum class FilterParamType : uint8_t {
31+
FREQUENCY,
32+
RESONANCE,
33+
MORPH,
34+
MODE,
35+
};
36+
37+
class FilterInfo {
38+
public:
39+
FilterInfo(FilterSlot slot_, FilterParamType type_) : slot{slot_}, type{type_} {}
40+
::FilterMode getMode() const {
41+
if (slot == FilterSlot::LPF) {
42+
return soundEditor.currentModControllable->lpfMode;
43+
}
44+
else {
45+
return soundEditor.currentModControllable->hpfMode;
46+
}
47+
}
48+
int32_t getModeValue() const {
49+
if (slot == FilterSlot::HPF) {
50+
return util::to_underlying(soundEditor.currentModControllable->hpfMode) - kFirstHPFMode;
51+
}
52+
else {
53+
// Off is located past the HPFLadder, which isn't an option for the low pass filter (should it be?)
54+
int32_t selection = util::to_underlying(soundEditor.currentModControllable->lpfMode);
55+
return std::min(selection, kNumLPFModes);
56+
}
57+
}
58+
void setMode(int32_t value) const {
59+
if (slot == FilterSlot::HPF) {
60+
soundEditor.currentModControllable->hpfMode = static_cast<FilterMode>(value + kFirstHPFMode);
61+
}
62+
else {
63+
// num lpf modes counts off but there's HPF modes in the middle
64+
if (value >= kNumLPFModes) {
65+
soundEditor.currentModControllable->lpfMode = FilterMode::OFF;
66+
}
67+
else {
68+
soundEditor.currentModControllable->lpfMode = static_cast<FilterMode>(value);
69+
}
70+
}
71+
}
72+
FilterParamType getFilterParamType() const { return type; }
73+
FilterSlot getSlot() const { return slot; }
74+
/// Returns morphname for morph parameters, and the alt argument for others.
75+
[[nodiscard]] std::string_view getMorphNameOr(std::string_view alt) const {
76+
if (type == FilterParamType::MORPH) {
77+
using enum l10n::String;
78+
auto filt = deluge::dsp::filter::SpecificFilter(getMode());
79+
return l10n::getView(filt.getMorphName());
80+
}
81+
else {
82+
return alt;
83+
}
84+
}
85+
bool isOn() const { return getMode() != ::FilterMode::OFF; }
86+
87+
private:
88+
FilterSlot slot;
89+
FilterParamType type;
90+
};
91+
92+
static_assert(sizeof(FilterInfo) <= 4);
93+
94+
} // namespace deluge::gui::menu_item::filter

src/deluge/gui/menu_item/filter/lpf_freq.h

-39
This file was deleted.

src/deluge/gui/menu_item/filter/lpf_mode.h

-55
This file was deleted.

0 commit comments

Comments
 (0)