Skip to content

Commit

Permalink
horizontal menus for LPF and HPF (#3147)
Browse files Browse the repository at this point in the history
- 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, DRV, BP, NTCH) to
  fit into a mode-column.

- Remove the special casing for filter freq display on 7-seg: it
  no longer display as OFF when fully open without modulation.

- 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.

- Rename the NONE filter mode to OFF, which seems clearer in the
  menu.

- Turning filter mode to oFF makes all other filter menu items
  non-relevant.
  • Loading branch information
nikodemus authored Jan 2, 2025
1 parent 5a7ca2b commit f07637a
Show file tree
Hide file tree
Showing 29 changed files with 486 additions and 303 deletions.
5 changes: 5 additions & 0 deletions src/deluge/gui/l10n/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,16 @@
"STRING_FOR_ANALOG": "Analog",

"STRING_FOR_DRIVE": "Drive",
"STRING_FOR_DRIVE_SHORT": "DRV",
"STRING_FOR_SVF_BAND": "SVF Bandpass",
"STRING_FOR_SVF_BAND_SHORT": "BP",
"STRING_FOR_SVF_NOTCH": "SVF Notch",
"STRING_FOR_SVF_NOTCH_SHORT": "NTCH",
"STRING_FOR_HPLADDER": "HP Ladder",
"STRING_FOR_12DB_LADDER": "12dB Ladder",
"STRING_FOR_12DB_LADDER_SHORT": "12dB",
"STRING_FOR_24DB_LADDER": "24dB Ladder",
"STRING_FOR_24DB_LADDER_SHORT": "24dB",
"STRING_FOR_FAST": "Fast",
"STRING_FOR_SLOW": "Slow",
"STRING_FOR_V_TRIGGER": "V-trig",
Expand Down
5 changes: 5 additions & 0 deletions src/deluge/gui/l10n/g_english.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,16 @@ PLACE_SDRAM_DATA Language english{
{STRING_FOR_DIGITAL, "Digital"},
{STRING_FOR_ANALOG, "Analog"},
{STRING_FOR_DRIVE, "Drive"},
{STRING_FOR_DRIVE_SHORT, "DRV"},
{STRING_FOR_SVF_BAND, "SVF Bandpass"},
{STRING_FOR_SVF_BAND_SHORT, "BP"},
{STRING_FOR_SVF_NOTCH, "SVF Notch"},
{STRING_FOR_SVF_NOTCH_SHORT, "NTCH"},
{STRING_FOR_HPLADDER, "HP Ladder"},
{STRING_FOR_12DB_LADDER, "12dB Ladder"},
{STRING_FOR_12DB_LADDER_SHORT, "12dB"},
{STRING_FOR_24DB_LADDER, "24dB Ladder"},
{STRING_FOR_24DB_LADDER_SHORT, "24dB"},
{STRING_FOR_FAST, "Fast"},
{STRING_FOR_SLOW, "Slow"},
{STRING_FOR_V_TRIGGER, "V-trig"},
Expand Down
5 changes: 5 additions & 0 deletions src/deluge/gui/l10n/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,16 @@ enum class String : size_t {

// gui/menu_item/filter/lpf_mode.h
STRING_FOR_DRIVE,
STRING_FOR_DRIVE_SHORT,
STRING_FOR_HPLADDER,
STRING_FOR_12DB_LADDER,
STRING_FOR_12DB_LADDER_SHORT,
STRING_FOR_24DB_LADDER,
STRING_FOR_24DB_LADDER_SHORT,
STRING_FOR_SVF_BAND,
STRING_FOR_SVF_BAND_SHORT,
STRING_FOR_SVF_NOTCH,
STRING_FOR_SVF_NOTCH_SHORT,

// gui/menu_item/flash/status.h
STRING_FOR_FAST,
Expand Down
2 changes: 0 additions & 2 deletions src/deluge/gui/menu_item/enumeration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ void Enumeration::selectEncoderAction(int32_t offset) {
nextValue = std::clamp<int32_t>(nextValue, 0, numOptions - 1);
}

D_PRINTLN("value = %d", nextValue);

setValue(nextValue);

// reset offset to account for wrapping
Expand Down
5 changes: 2 additions & 3 deletions src/deluge/gui/menu_item/enumeration.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ class Enumeration : public Value<int32_t> {
void beginSession(MenuItem* navigatedBackwardFrom) override;
void selectEncoderAction(int32_t offset) override;
virtual size_t size() = 0;
/// @brief Should this menu wrap around? Destined to be virtualized and moved higher
/// in the class hierarchy.
bool wrapAround();
/// @brief Should this menu wrap around?
virtual bool wrapAround();

protected:
void drawPixelsForOled() override = 0;
Expand Down
39 changes: 0 additions & 39 deletions src/deluge/gui/menu_item/filter/hpf_freq.h

This file was deleted.

46 changes: 0 additions & 46 deletions src/deluge/gui/menu_item/filter/hpf_mode.h

This file was deleted.

94 changes: 94 additions & 0 deletions src/deluge/gui/menu_item/filter/info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2014-2023 Synthstrom Audible Limited
*
* This file is part of The Synthstrom Audible Deluge Firmware.
*
* The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once

#include "gui/ui/sound_editor.h"
#include "model/mod_controllable/filters/filter_config.h"
#include "modulation/patch/patch_cable_set.h"

namespace deluge::gui::menu_item::filter {

enum class FilterSlot : uint8_t {
LPF,
HPF,
};

enum class FilterParamType : uint8_t {
FREQUENCY,
RESONANCE,
MORPH,
MODE,
};

class FilterInfo {
public:
FilterInfo(FilterSlot slot_, FilterParamType type_) : slot{slot_}, type{type_} {}
::FilterMode getMode() const {
if (slot == FilterSlot::LPF) {
return soundEditor.currentModControllable->lpfMode;
}
else {
return soundEditor.currentModControllable->hpfMode;
}
}
int32_t getModeValue() const {
if (slot == FilterSlot::HPF) {
return util::to_underlying(soundEditor.currentModControllable->hpfMode) - kFirstHPFMode;
}
else {
// Off is located past the HPFLadder, which isn't an option for the low pass filter (should it be?)
int32_t selection = util::to_underlying(soundEditor.currentModControllable->lpfMode);
return std::min(selection, kNumLPFModes);
}
}
void setMode(int32_t value) const {
if (slot == FilterSlot::HPF) {
soundEditor.currentModControllable->hpfMode = static_cast<FilterMode>(value + kFirstHPFMode);
}
else {
// num lpf modes counts off but there's HPF modes in the middle
if (value >= kNumLPFModes) {
soundEditor.currentModControllable->lpfMode = FilterMode::OFF;
}
else {
soundEditor.currentModControllable->lpfMode = static_cast<FilterMode>(value);
}
}
}
FilterParamType getFilterParamType() const { return type; }
FilterSlot getSlot() const { return slot; }
/// Returns morphname for morph parameters, and the alt argument for others.
[[nodiscard]] std::string_view getMorphNameOr(std::string_view alt) const {
if (type == FilterParamType::MORPH) {
using enum l10n::String;
auto filt = deluge::dsp::filter::SpecificFilter(getMode());
return l10n::getView(filt.getMorphName());
}
else {
return alt;
}
}
bool isOn() const { return getMode() != ::FilterMode::OFF; }

private:
FilterSlot slot;
FilterParamType type;
};

static_assert(sizeof(FilterInfo) <= 4);

} // namespace deluge::gui::menu_item::filter
39 changes: 0 additions & 39 deletions src/deluge/gui/menu_item/filter/lpf_freq.h

This file was deleted.

55 changes: 0 additions & 55 deletions src/deluge/gui/menu_item/filter/lpf_mode.h

This file was deleted.

Loading

0 comments on commit f07637a

Please sign in to comment.