Deluge Firmware 1.3.0
Build date: 2026.10.14
Loading...
Searching...
No Matches
sound_editor.h
1/*
2 * Copyright © 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
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "gui/menu_item/menu_item.h"
22#include "gui/ui/ui.h"
23#include "hid/button.h"
24#include "modulation/arpeggiator.h"
25
26#define SHORTCUTS_VERSION_1 0
27#define SHORTCUTS_VERSION_3 1
28#define NUM_SHORTCUTS_VERSIONS 2
29
30extern void enterEditor();
31extern void enterSaveSynthPresetUI();
32
33class Drum;
34class Sound;
35class Source;
37class InstrumentClip;
38class SideChain;
39class Arpeggiator;
41class Clip;
42class SampleHolder;
43class SampleControls;
46class AudioFileHolder;
47class MIDICable;
48
49namespace deluge::gui::menu_item {
50class Submenu;
51class HorizontalMenu;
52enum class RangeEdit : uint8_t;
53} // namespace deluge::gui::menu_item
54
55class SoundEditor final : public UI {
56public:
57 SoundEditor();
58 bool opened() override;
59 void focusRegained() override;
60 void displayOrLanguageChanged() final;
61 bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) override;
62 Sound* currentSound;
63 bool allowsNoteTails;
64 ModControllableAudio* currentModControllable;
65 int8_t currentSourceIndex;
66 Source* currentSource;
67 ParamManagerForTimeline* currentParamManager;
68 SideChain* currentSidechain;
69 ArpeggiatorSettings* currentArpSettings;
70 ::MultiRange* currentMultiRange;
71 SampleControls* currentSampleControls;
72 VoicePriority* currentPriority;
73 int16_t currentMultiRangeIndex;
74 MIDICable* currentMIDICable;
75 deluge::gui::menu_item::RangeEdit editingRangeEdge;
76 bool haveRenderedPads{false};
77
78 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
79 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
80 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
81 void modEncoderAction(int32_t whichModEncoder, int32_t offset) override;
82 void modEncoderButtonAction(uint8_t whichModEncoder, bool on) override;
83 ActionResult horizontalEncoderAction(int32_t offset) override;
84 void scrollFinished() override;
85 static bool editingKit();
86
88 bool editingKitAffectEntire() const;
89
91 static bool shouldEditKitAffectEntire();
92 bool editingKitRow();
93 void setCurrentSource(int32_t sourceIndex);
94
95 bool should_render_shortcut_overlay();
96 bool in_sound_editor();
97 bool renderMainPads(uint32_t whichRows, RGB image[kDisplayHeight][kDisplayWidth + kSideBarWidth],
98 uint8_t occupancyMask[kDisplayHeight][kDisplayWidth + kSideBarWidth],
99 bool drawUndefinedArea = false) override;
100 static void renderMainShortcutsOnly(ModControllableAudio* forThing, RGB image[][kDisplayWidth + kSideBarWidth],
101 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], bool doKitAffectEntire);
102
103 ActionResult timerCallback() override;
104 void setupShortcutBlink(int32_t x, int32_t y, int32_t frequency, int32_t colour = 0L);
105 bool findPatchedParam(int32_t paramLookingFor, int32_t* xout, int32_t* yout, bool* isSecondLayerParamOut);
106 void updateSourceBlinks(MenuItem* currentItem);
107 void resetSourceBlinks();
108
109 uint8_t navigationDepth;
110 uint8_t patchingParamSelected;
111 uint8_t currentParamShortcutX;
112 uint8_t currentParamShortcutY;
113 uint8_t currentParamColour;
114 uint8_t paramShortcutBlinkFrequency;
115 uint32_t shortcutBlinkCounter;
116
117 uint32_t timeLastAttemptedAutomatedParamEdit;
118
119 int8_t numberScrollAmount;
120 uint32_t numberEditSize;
121 int8_t numberEditPos;
122
123 uint8_t shortcutsVersion;
124
125 MenuItem* menuItemNavigationRecord[16];
126
127 bool shouldGoUpOneLevelOnBegin;
128 bool secondLayerShortcutsToggled;
129 bool secondLayerModSourceShortcutsToggled;
130
131 bool programChangeReceived(MIDICable& cable, uint8_t channel, uint8_t program) { return false; }
132 bool midiCCReceived(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value);
133 bool pitchBendReceived(MIDICable& cable, uint8_t channel, uint8_t data1, uint8_t data2);
134 void selectEncoderAction(int8_t offset) override;
135 bool canSeeViewUnderneath() override { return true; }
136 bool setup(Clip* clip = nullptr, const MenuItem* item = nullptr, int32_t sourceIndex = 0);
137 void enterOrUpdateSoundEditor(bool on);
138 void blinkShortcut();
139 ActionResult potentialShortcutPadAction(int32_t x, int32_t y, bool on);
140 bool editingReverbSidechain();
141 MenuItem* getCurrentMenuItem();
142 bool inSettingsMenu();
143 bool setupKitGlobalFXMenu;
144 ActionResult exitUI() override { return exitCompletely(); };
145 ActionResult exitCompletely();
146 void goUpOneLevel();
147 void enterSubmenu(MenuItem* newItem, MenuItem* navigatedBackwardFrom = nullptr);
148 bool pcReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t program) override;
149 bool noteOnReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t note, int32_t velocity) override;
150 void markInstrumentAsEdited();
152 static std::tuple<MenuItem*, bool> get_basic_shortcut_action(int32_t x, int32_t y, bool doKitAffectEntire);
153 static bool editingCVOrMIDIClip();
154 static bool editingNonAudioDrumRow();
155 static bool editingNothing();
156 static bool editingMidiDrumRow();
157 static bool editingGateDrumRow();
158 bool isUntransposedNoteWithinRange(int32_t noteCode);
159 void setCurrentMultiRange(int32_t i);
160 void possibleChangeToCurrentRangeDisplay();
161 MenuPermission checkPermissionToBeginSessionForRangeSpecificParam(Sound* sound, int32_t whichThing,
162 ::MultiRange** previouslySelectedRange);
163 void setupExclusiveShortcutBlink(int32_t x, int32_t y);
164 void setShortcutsVersion(int32_t newVersion);
165 ModelStackWithThreeMainThings* getCurrentModelStack(void* memory);
166
167 void cutSound();
168 AudioFileHolder* getCurrentAudioFileHolder();
169 void mpeZonesPotentiallyUpdated();
170
171 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
172
173 // ui
174 UIType getUIType() override { return UIType::SOUND_EDITOR; }
175
176 bool selectedNoteRow;
177
178 // Note / Note Row Editor
179 bool inNoteEditor();
180 bool inNoteRowEditor();
181 void toggleNoteEditorParamMenu(int32_t on);
182 void updatePadLightsFor(MenuItem* item);
183
184 // Horizontal menus
185 deluge::gui::menu_item::HorizontalMenu* maybeGetParentMenu(MenuItem* item);
186 std::optional<std::span<deluge::gui::menu_item::HorizontalMenu* const>>
187 getCurrentHorizontalMenusChain(bool checkNavigationDepth = true);
188
189private:
191 void setupShortcutsBlinkFromTable(MenuItem const* currentItem,
192 MenuItem const* const items[kDisplayWidth][kDisplayHeight]);
193 bool beginScreen(MenuItem* oldMenuItem = nullptr);
194 void endScreen();
195 uint8_t getActualParamFromScreen(uint8_t screen);
196 void setLedStates();
197 ActionResult handleAutomationViewPadAction(int32_t x, int32_t y, int32_t velocity);
198 bool isEditingAutomationViewParam();
199 void handlePotentialParamMenuChange(deluge::hid::Button b, bool inCardRoutine, MenuItem* previousItem,
200 MenuItem* currentItem, bool isHorizontalMenu);
201
202 uint8_t sourceShortcutBlinkFrequencies[2][kDisplayHeight];
203 uint8_t sourceShortcutBlinkColours[2][kDisplayHeight];
204};
205
206extern SoundEditor soundEditor;
Definition arpeggiator.h:48
Definition arpeggiator.h:363
Definition audio_file_holder.h:30
Definition clip.h:46
Definition drum.h:44
Definition instrument_clip.h:48
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:96
Base class for all menu items.
Definition menu_item.h:50
Definition mod_controllable_audio.h:47
Definition model_stack.h:231
Definition multi_range.h:23
Definition multisample_range.h:27
Definition param_manager.h:175
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition sample_controls.h:22
Definition sample_holder.h:32
Definition sidechain.h:27
Definition sound_editor.h:55
UIType getUIType() override
What type of UI is this? e.g. UIType::ARRANGER.
Definition sound_editor.h:174
static bool shouldEditKitAffectEntire()
returns whether the sound editor should open to edit a kit's global stuff. Matches affect entire when...
Definition sound_editor.cpp:358
void handlePotentialParamMenuChange(deluge::hid::Button b, bool inCardRoutine, MenuItem *previousItem, MenuItem *currentItem, bool isHorizontalMenu)
Definition sound_editor.cpp:856
void endScreen()
end current menu item session before beginning new menu item session or exiting the sound editor
Definition sound_editor.cpp:1171
static std::tuple< MenuItem *, bool > get_basic_shortcut_action(int32_t x, int32_t y, bool doKitAffectEntire)
Checks ONLY the basic top level shortcut. Does not handle layers or whether patch cables are possible...
Definition sound_editor.cpp:1356
static bool editingNothing()
edge case of having a kit but no drum selected and not affect entire
Definition sound_editor.cpp:384
bool editingKitAffectEntire() const
whether the sound editor is editing a kit's global stuff. Matches affect entire at time of opening
Definition sound_editor.cpp:354
ActionResult exitUI() override
returns whether a UI exited
Definition sound_editor.h:144
void setupShortcutsBlinkFromTable(MenuItem const *currentItem, MenuItem const *const items[kDisplayWidth][kDisplayHeight])
Setup shortcut blinking by finding the given menu item in the provided item map.
Definition sound_editor.cpp:1013
Definition sound.h:76
Definition source.h:31
Definition horizontal_menu.h:29
Definition submenu.h:28