Deluge Firmware 1.3.0
Build date: 2026.11.13
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
130 bool programChangeReceived(MIDICable& cable, uint8_t channel, uint8_t program) { return false; }
131 bool midiCCReceived(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value);
132 bool pitchBendReceived(MIDICable& cable, uint8_t channel, uint8_t data1, uint8_t data2);
133 void selectEncoderAction(int8_t offset) override;
134 bool canSeeViewUnderneath() override { return true; }
135 bool setup(Clip* clip = nullptr, const MenuItem* item = nullptr, int32_t sourceIndex = 0);
136 void enterOrUpdateSoundEditor(bool on);
137 void blinkShortcut();
138 ActionResult potentialShortcutPadAction(int32_t x, int32_t y, bool on);
139 bool editingReverbSidechain();
140 MenuItem* getCurrentMenuItem();
141 bool inSettingsMenu();
142 bool setupKitGlobalFXMenu;
143 ActionResult exitUI() override { return exitCompletely(); };
144 ActionResult exitCompletely();
145 void goUpOneLevel();
146 void enterSubmenu(MenuItem* newItem, MenuItem* navigatedBackwardFrom = nullptr);
147 bool pcReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t program) override;
148 bool noteOnReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t note, int32_t velocity) override;
149 void markInstrumentAsEdited();
151 static std::tuple<MenuItem*, bool> get_basic_shortcut_action(int32_t x, int32_t y, bool doKitAffectEntire);
152 static bool editingCVOrMIDIClip();
153 static bool editingNonAudioDrumRow();
154 static bool editingNothing();
155 static bool editingMidiDrumRow();
156 static bool editingGateDrumRow();
157 bool isUntransposedNoteWithinRange(int32_t noteCode);
158 void setCurrentMultiRange(int32_t i);
159 void possibleChangeToCurrentRangeDisplay();
160 MenuPermission checkPermissionToBeginSessionForRangeSpecificParam(Sound* sound, int32_t whichThing,
161 ::MultiRange** previouslySelectedRange);
162 void setupExclusiveShortcutBlink(int32_t x, int32_t y);
163 void setShortcutsVersion(int32_t newVersion);
164 ModelStackWithThreeMainThings* getCurrentModelStack(void* memory);
165
166 void cutSound();
167 AudioFileHolder* getCurrentAudioFileHolder();
168 void mpeZonesPotentiallyUpdated();
169
170 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
171
172 // ui
173 UIType getUIType() override { return UIType::SOUND_EDITOR; }
174
175 bool selectedNoteRow;
176
177 // Note / Note Row Editor
178 bool inNoteEditor();
179 bool inNoteRowEditor();
180 void toggleNoteEditorParamMenu(int32_t on);
181 void updatePadLightsFor(MenuItem* item);
182
183 // Horizontal menus
184 deluge::gui::menu_item::HorizontalMenu* maybeGetParentMenu(MenuItem* item);
185 std::optional<std::span<deluge::gui::menu_item::HorizontalMenu* const>>
186 getCurrentHorizontalMenusChain(bool checkNavigationDepth = true);
187
188private:
190 void setupShortcutsBlinkFromTable(MenuItem const* currentItem,
191 MenuItem const* const items[kDisplayWidth][kDisplayHeight]);
192 bool beginScreen(MenuItem* oldMenuItem = nullptr);
193 void endScreen();
194 uint8_t getActualParamFromScreen(uint8_t screen);
195 void setLedStates();
196 ActionResult handleAutomationViewPadAction(int32_t x, int32_t y, int32_t velocity);
197 bool isEditingAutomationViewParam();
198 void handlePotentialParamMenuChange(deluge::hid::Button b, bool inCardRoutine, MenuItem* previousItem,
199 MenuItem* currentItem, bool isHorizontalMenu);
200
201 uint8_t sourceShortcutBlinkFrequencies[2][kDisplayHeight];
202 uint8_t sourceShortcutBlinkColours[2][kDisplayHeight];
203 bool source_shortcut_blink_alternates[2][kDisplayHeight];
204};
205
206extern SoundEditor soundEditor;
Definition arpeggiator.h:48
Definition arpeggiator.h:365
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:52
Definition mod_controllable_audio.h:47
Definition model_stack.h:227
Definition multi_range.h:23
Definition multisample_range.h:27
Definition param_manager.h:155
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:173
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:400
void handlePotentialParamMenuChange(deluge::hid::Button b, bool inCardRoutine, MenuItem *previousItem, MenuItem *currentItem, bool isHorizontalMenu)
Definition sound_editor.cpp:903
void endScreen()
end current menu item session before beginning new menu item session or exiting the sound editor
Definition sound_editor.cpp:1230
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:1418
static bool editingNothing()
edge case of having a kit but no drum selected and not affect entire
Definition sound_editor.cpp:425
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:396
ActionResult exitUI() override
returns whether a UI exited
Definition sound_editor.h:143
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:1066
Definition sound.h:77
Definition source.h:31
Definition horizontal_menu.h:29
Definition submenu.h:28