Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
type.h
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#include "definitions_cxx.hpp"
19#include "gui/ui/sound_editor.h"
20#include "model/drum/drum.h"
21#include "model/instrument/kit.h"
22#include "model/song/song.h"
23#include "processing/sound/sound.h"
24#include "processing/sound/sound_drum.h"
25
26namespace deluge::gui::menu_item::lfo {
27
28class Type final : public Selection, FormattedTitle {
29public:
30 Type(l10n::String name, l10n::String title, uint8_t lfoId)
31 : Selection(name, title), FormattedTitle(title, lfoId + 1), lfoId_(lfoId) {}
32
33 [[nodiscard]] std::string_view getTitle() const override { return FormattedTitle::title(); }
34
35 deluge::vector<std::string_view> getOptions(OptType optType) override {
36 using enum l10n::String;
37 bool shortOpt = optType == OptType::SHORT;
38 return {
39 l10n::getView(STRING_FOR_SINE),
40 l10n::getView(STRING_FOR_TRIANGLE),
41 l10n::getView(STRING_FOR_SQUARE),
42 l10n::getView(STRING_FOR_SAW),
43 l10n::getView(STRING_FOR_SAMPLE_AND_HOLD),
44 l10n::getView(shortOpt ? STRING_FOR_RANDOM_WALK_SHORT : STRING_FOR_RANDOM_WALK),
45 l10n::getView(STRING_FOR_WARBLE),
46 };
47 }
48
49 void readCurrentValue() override { this->setValue(soundEditor.currentSound->lfoConfig[lfoId_].waveType); }
50 bool usesAffectEntire() override { return true; }
51 void writeCurrentValue() override {
52 auto current_value = this->getValue<LFOType>();
53 // If affect-entire button held, do whole kit
54 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
55
56 Kit* kit = getCurrentKit();
57
58 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
59 if (thisDrum->type == DrumType::SOUND) {
60 auto* soundDrum = static_cast<SoundDrum*>(thisDrum);
61 soundDrum->lfoConfig[lfoId_].waveType = current_value;
62 // This fires unnecessarily for LFO2 assignments as well, but that's ok. It's not
63 // entirely clear if we really need this for the LFO1, even: maybe the clock-driven resyncs
64 // would be enough?
65 soundDrum->resyncGlobalLFOs();
66 }
67 }
68 }
69 // Or, the normal case of just one sound
70 else {
71 soundEditor.currentSound->lfoConfig[lfoId_].waveType = current_value;
72 // This fires unnecessarily for LFO2 assignments as well, but that's ok. It's not
73 // entirely clear if we really need this for the LFO1, even: maybe the clock-driven resyncs
74 // would be enough?
75 soundEditor.currentSound->resyncGlobalLFOs();
76 }
77 }
78
79 [[nodiscard]] bool showColumnLabel() const override { return false; }
80 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height) override {
81 oled_canvas::Canvas& image = OLED::main;
82
83 const Icon& icon = [&] {
84 switch (soundEditor.currentSound->lfoConfig[lfoId_].waveType) {
85 case LFOType::SINE:
86 return OLED::sineIcon;
87 case LFOType::TRIANGLE:
88 return OLED::triangleIcon;
89 case LFOType::SQUARE:
90 return OLED::squareIcon;
91 case LFOType::SAW:
92 return OLED::sawIcon;
93 case LFOType::SAMPLE_AND_HOLD:
94 return OLED::sampleHoldIcon;
95 case LFOType::RANDOM_WALK:
96 return OLED::randomWalkIcon;
97 case LFOType::WARBLER:
98 return OLED::warblerIcon;
99 }
100 return OLED::sineIcon;
101 }();
102
103 image.drawIconCentered(icon, startX, width, startY + 4);
104 }
105
106private:
107 uint8_t lfoId_;
108};
109
110} // namespace deluge::gui::menu_item::lfo
Definition drum.h:44
Definition kit.h:34
Definition sound_drum.h:28
Definition selection.h:26
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition type.h:50
bool showColumnLabel() const override
Show a label for the parameter in Horizontal menu.
Definition type.h:79
std::string_view getTitle() const override
Get the title to be used when rendering on OLED, both as a deluge::gui::menu_item::Submenu and when d...
Definition type.h:33
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition type.h:49