Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
mode.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/menu_item/selection.h"
20#include "gui/ui/sound_editor.h"
21#include "model/clip/clip.h"
22#include "model/clip/instrument_clip.h"
23#include "model/drum/drum.h"
24#include "model/instrument/kit.h"
25#include "model/model_stack.h"
26#include "model/song/song.h"
27#include "processing/sound/sound.h"
28
29namespace deluge::gui::menu_item::arpeggiator {
30class Mode final : public Selection {
31public:
32 using Selection::Selection;
33 void readCurrentValue() override { this->setValue(soundEditor.currentArpSettings->mode); }
34
35 bool usesAffectEntire() override { return true; }
36 void writeCurrentValue() override {
37 auto current_value = this->getValue<ArpMode>();
38
39 // If affect-entire button held, do whole kit
40 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
41
42 Kit* kit = getCurrentKit();
43
44 // If was off, or is now becoming off...
45 if (soundEditor.currentArpSettings->mode == ArpMode::OFF || current_value == ArpMode::OFF) {
46 if (getCurrentClip()->isActiveOnOutput() && !soundEditor.editingKitAffectEntire()) {
47 kit->cutAllSound();
48 }
49 }
50
51 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
52 thisDrum->arpSettings.mode = current_value;
53 thisDrum->arpSettings.updatePresetFromCurrentSettings();
54 }
55 }
56 // Or, the normal case of just one sound
57 else {
58 // If was off, or is now becoming off...
59 if (soundEditor.currentArpSettings->mode == ArpMode::OFF || current_value == ArpMode::OFF) {
60 if (getCurrentClip()->isActiveOnOutput() && !soundEditor.editingKitAffectEntire()) {
61 char modelStackMemory[MODEL_STACK_MAX_SIZE];
62 ModelStackWithThreeMainThings* modelStack = soundEditor.getCurrentModelStack(modelStackMemory);
63
64 if (soundEditor.editingKit()) {
65 // Drum
66 Drum* currentDrum = ((Kit*)getCurrentClip()->output)->selectedDrum;
67 if (currentDrum != nullptr) {
68 currentDrum->killAllVoices();
69 }
70 }
71 else if (soundEditor.editingCVOrMIDIClip()) {
72 getCurrentInstrumentClip()->stopAllNotesForMIDIOrCV(modelStack->toWithTimelineCounter());
73 }
74 else {
75 ModelStackWithSoundFlags* modelStackWithSoundFlags = modelStack->addSoundFlags();
76 soundEditor.currentSound->allNotesOff(
77 modelStackWithSoundFlags,
78 soundEditor.currentSound
79 ->getArp()); // Must switch off all notes when switching arp on / off
80 soundEditor.currentSound->reassessRenderSkippingStatus(modelStackWithSoundFlags);
81 }
82 }
83 }
84
85 soundEditor.currentArpSettings->mode = current_value;
86 soundEditor.currentArpSettings->updatePresetFromCurrentSettings();
87 }
88 }
89
90 deluge::vector<std::string_view> getOptions(OptType optType) override {
91 (void)optType;
92 using enum l10n::String;
93 return {
94 l10n::getView(STRING_FOR_OFF), //<
95 l10n::getView(STRING_FOR_ON), //<
96 };
97 }
98
99 // flag this selection menu as a toggle menu so we can use a checkbox to toggle value
100 bool isToggle() override { return true; }
101
102 // don't enter menu on select button press
103 bool shouldEnterSubmenu() override { return false; }
104};
105} // namespace deluge::gui::menu_item::arpeggiator
Definition drum.h:44
Definition kit.h:34
Definition model_stack.h:231
Definition selection.h:26
bool shouldEnterSubmenu() override
Check if selecting this menu item (with select encoder) should enter a submenu.
Definition mode.h:103
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition mode.h:33
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition mode.h:35