Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
chord_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/l10n/l10n.h"
20#include "gui/l10n/strings.h"
21#include "gui/menu_item/selection.h"
22#include "gui/ui/sound_editor.h"
23#include "model/drum/drum.h"
24#include "model/instrument/kit.h"
25#include "model/song/song.h"
26#include "processing/sound/sound.h"
27#include <cstdint>
28
29namespace deluge::gui::menu_item::arpeggiator {
30class ChordType : public Selection {
31public:
32 using Selection::Selection;
33 void readCurrentValue() override { this->setValue(soundEditor.currentArpSettings->chordTypeIndex); }
34
35 bool usesAffectEntire() override { return true; }
36 void writeCurrentValue() override {
37 int32_t current_value = this->getValue();
38 if (current_value < 0 || current_value >= MAX_CHORD_TYPES) {
39 return;
40 }
41
42 // If affect-entire button held, do whole kit
43 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
44
45 Kit* kit = getCurrentKit();
46
47 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
48 // Note: we need to apply the same filtering as stated in the isRelevant() function
49 if (thisDrum->type != DrumType::GATE) {
50 thisDrum->arpSettings.chordTypeIndex = current_value;
51 thisDrum->arpSettings.flagForceArpRestart = true;
52 }
53 }
54 }
55 // Or, the normal case of just one sound
56 else {
57 soundEditor.currentArpSettings->chordTypeIndex = current_value;
58 soundEditor.currentArpSettings->flagForceArpRestart = true;
59 }
60 }
61
62 bool isRelevant(ModControllableAudio* modControllable, int32_t whichThing) override {
63 return soundEditor.editingKitRow() && !soundEditor.editingGateDrumRow();
64 }
65 void getColumnLabel(StringBuf& label) override {
66 label.append(deluge::l10n::get(deluge::l10n::built_in::seven_segment, this->name));
67 }
68
69 deluge::vector<std::string_view> getOptions(OptType optType) override {
70 (void)optType;
71 using enum l10n::String;
72 return {
73 l10n::getView(STRING_FOR_NONE), //<
74 l10n::getView(STRING_FOR_FIFTH), //<
75 l10n::getView(STRING_FOR_SUS2), //<
76 l10n::getView(STRING_FOR_MINOR), //<
77 l10n::getView(STRING_FOR_MAJOR), //<
78 l10n::getView(STRING_FOR_SUS4), //<
79 l10n::getView(STRING_FOR_MINOR7), //<
80 l10n::getView(STRING_FOR_DOMINANT7), //<
81 l10n::getView(STRING_FOR_MAJOR7), //<
82 };
83 }
84};
85
86} // namespace deluge::gui::menu_item::arpeggiator
Definition drum.h:44
Definition kit.h:34
Definition mod_controllable_audio.h:47
Definition d_string.h:106
Definition selection.h:26
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition chord_type.h:33
void getColumnLabel(StringBuf &label) override
Get the name for use on horizontal menus.
Definition chord_type.h:65
bool isRelevant(ModControllableAudio *modControllable, int32_t whichThing) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition chord_type.h:62
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition chord_type.h:35