Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
include_in_kit_arp.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 "gui/l10n/strings.h"
19#include "gui/menu_item/selection.h"
20#include "gui/ui/sound_editor.h"
21#include "model/drum/drum.h"
22#include "model/instrument/kit.h"
23#include "model/song/song.h"
24#include "processing/sound/sound.h"
25#include "processing/sound/sound_drum.h"
26
27namespace deluge::gui::menu_item::arpeggiator {
28class IncludeInKitArp final : public Selection {
29public:
30 using Selection::Selection;
31 void readCurrentValue() override {
32 if (!soundEditor.allowsNoteTails) {
33 this->setValue(0);
34 }
35 else {
36 this->setValue(soundEditor.currentArpSettings->includeInKitArp);
37 }
38 }
39 bool usesAffectEntire() override { return true; }
40 void writeCurrentValue() override {
41 auto current_value = this->getValue();
42
43 // If affect-entire button held, do whole kit
44 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
45
46 Kit* kit = getCurrentKit();
47
48 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
49 bool allowsNoteTails = true;
50 if (thisDrum->type == DrumType::SOUND) {
51 auto* soundDrum = static_cast<SoundDrum*>(thisDrum);
52
53 char modelStackMemoryForSoundDrum[MODEL_STACK_MAX_SIZE];
54 ModelStackWithSoundFlags* modelStackForSoundDrum =
55 getModelStackFromSoundDrum(modelStackMemoryForSoundDrum, soundDrum)->addSoundFlags();
56 allowsNoteTails = soundDrum->allowNoteTails(modelStackForSoundDrum, true);
57 }
58
59 if (allowsNoteTails) {
60 thisDrum->arpSettings.includeInKitArp = current_value != 0;
61 }
62 }
63 }
64 // Or, the normal case of just one sound
65 else {
66 if (soundEditor.allowsNoteTails) {
67 soundEditor.currentArpSettings->includeInKitArp = current_value != 0;
68 }
69 }
70 }
71
72 deluge::vector<std::string_view> getOptions(OptType optType) override {
73 (void)optType;
74 using enum l10n::String;
75 return {
76 l10n::getView(STRING_FOR_OFF), //<
77 l10n::getView(STRING_FOR_ON), //<
78 };
79 }
80
81 bool isRelevant(ModControllableAudio* modControllable, int32_t whichThing) override {
82 return soundEditor.editingKitRow();
83 }
84
85 void getColumnLabel(StringBuf& label) override {
86 label.append(deluge::l10n::getView(deluge::l10n::built_in::seven_segment, this->name).data());
87 }
88
89 // flag this selection menu as a toggle menu so we can use a checkbox to toggle value
90 bool isToggle() override { return true; }
91
92 // don't enter menu on select button press
93 bool shouldEnterSubmenu() override { return false; }
94};
95} // namespace deluge::gui::menu_item::arpeggiator
Definition drum.h:44
Definition kit.h:34
Definition mod_controllable_audio.h:47
Definition model_stack.h:287
Definition sound_drum.h:28
Definition d_string.h:106
Definition selection.h:26
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition include_in_kit_arp.h:31
bool isRelevant(ModControllableAudio *modControllable, int32_t whichThing) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition include_in_kit_arp.h:81
void getColumnLabel(StringBuf &label) override
Get the name for use on horizontal menus.
Definition include_in_kit_arp.h:85
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition include_in_kit_arp.h:39
bool shouldEnterSubmenu() override
Check if selecting this menu item (with select encoder) should enter a submenu.
Definition include_in_kit_arp.h:93