Deluge Firmware 1.3.0
Build date: 2025.09.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
77 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
78 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
79 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
80 void modEncoderAction(int32_t whichModEncoder, int32_t offset) override;
81 void modEncoderButtonAction(uint8_t whichModEncoder, bool on) override;
82 ActionResult horizontalEncoderAction(int32_t offset) override;
83 void scrollFinished() override;
84 bool editingKit();
85 bool editingKitAffectEntire();
86 bool editingKitRow();
87 void setCurrentSource(int32_t sourceIndex);
88
89 ActionResult timerCallback() override;
90 void setupShortcutBlink(int32_t x, int32_t y, int32_t frequency, int32_t colour = 0L);
91 bool findPatchedParam(int32_t paramLookingFor, int32_t* xout, int32_t* yout, bool* isSecondLayerParamOut);
92 void updateSourceBlinks(MenuItem* currentItem);
93 void resetSourceBlinks();
94
95 uint8_t navigationDepth;
96 uint8_t patchingParamSelected;
97 uint8_t currentParamShorcutX;
98 uint8_t currentParamShorcutY;
99 uint8_t currentParamColour;
100 uint8_t paramShortcutBlinkFrequency;
101 uint32_t shortcutBlinkCounter;
102
103 uint32_t timeLastAttemptedAutomatedParamEdit;
104
105 int8_t numberScrollAmount;
106 uint32_t numberEditSize;
107 int8_t numberEditPos;
108
109 uint8_t shortcutsVersion;
110
111 MenuItem* menuItemNavigationRecord[16];
112
113 bool shouldGoUpOneLevelOnBegin;
114 bool secondLayerShortcutsToggled;
115 bool secondLayerModSourceShortcutsToggled;
116
117 bool programChangeReceived(MIDICable& cable, uint8_t channel, uint8_t program) { return false; }
118 bool midiCCReceived(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value);
119 bool pitchBendReceived(MIDICable& cable, uint8_t channel, uint8_t data1, uint8_t data2);
120 void selectEncoderAction(int8_t offset) override;
121 bool canSeeViewUnderneath() override { return true; }
122 bool setup(Clip* clip = nullptr, const MenuItem* item = nullptr, int32_t sourceIndex = 0);
123 void enterOrUpdateSoundEditor(bool on);
124 void blinkShortcut();
125 ActionResult potentialShortcutPadAction(int32_t x, int32_t y, bool on);
126 bool editingReverbSidechain();
127 MenuItem* getCurrentMenuItem();
128 bool inSettingsMenu();
129 bool setupKitGlobalFXMenu;
130 bool exitUI() override {
131 exitCompletely();
132 return true;
133 };
134 void exitCompletely();
135 void goUpOneLevel();
136 void enterSubmenu(MenuItem* newItem);
137 bool pcReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t program) override;
138 bool noteOnReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t note, int32_t velocity) override;
139 void markInstrumentAsEdited();
140 bool editingCVOrMIDIClip();
141 bool editingNonAudioDrumRow();
142 bool editingMidiDrumRow();
143 bool editingGateDrumRow();
144 bool isUntransposedNoteWithinRange(int32_t noteCode);
145 void setCurrentMultiRange(int32_t i);
146 void possibleChangeToCurrentRangeDisplay();
147 MenuPermission checkPermissionToBeginSessionForRangeSpecificParam(Sound* sound, int32_t whichThing,
148 ::MultiRange** previouslySelectedRange);
149 void setupExclusiveShortcutBlink(int32_t x, int32_t y);
150 void setShortcutsVersion(int32_t newVersion);
151 ModelStackWithThreeMainThings* getCurrentModelStack(void* memory);
152
153 void cutSound();
154 AudioFileHolder* getCurrentAudioFileHolder();
155 void mpeZonesPotentiallyUpdated();
156
157 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
158
159 // ui
160 UIType getUIType() override { return UIType::SOUND_EDITOR; }
161
162 bool selectedNoteRow;
163
164 // Note / Note Row Editor
165 bool inNoteEditor();
166 bool inNoteRowEditor();
167 void toggleNoteEditorParamMenu(int32_t on);
168 void updatePadLightsFor(MenuItem* item);
169
170 // Horizontal menus
171 deluge::gui::menu_item::HorizontalMenu* maybeGetParentMenu(MenuItem* item);
172 std::optional<std::span<deluge::gui::menu_item::HorizontalMenu* const>>
173 getCurrentHorizontalMenusChain(bool checkNavigationDepth = true);
174
175private:
177 void setupShortcutsBlinkFromTable(MenuItem const* currentItem,
178 MenuItem const* const items[kDisplayWidth][kDisplayHeight]);
179 bool beginScreen(MenuItem* oldMenuItem = nullptr);
180 void endScreen();
181 uint8_t getActualParamFromScreen(uint8_t screen);
182 void setLedStates();
183 ActionResult handleAutomationViewPadAction(int32_t x, int32_t y, int32_t velocity);
184 bool isEditingAutomationViewParam();
185 void handlePotentialParamMenuChange(deluge::hid::Button b, bool on, bool inCardRoutine, MenuItem* previousItem,
186 MenuItem* currentItem);
187
188 uint8_t sourceShortcutBlinkFrequencies[2][kDisplayHeight];
189 uint8_t sourceShortcutBlinkColours[2][kDisplayHeight];
190};
191
192extern SoundEditor soundEditor;
Definition arpeggiator.h:46
Definition arpeggiator.h:330
Definition audio_file_holder.h:30
Definition clip.h:46
Definition drum.h:44
Definition instrument_clip.h:47
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Base class for all menu items.
Definition menu_item.h:43
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:174
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:160
bool exitUI() override
returns whether a UI exited
Definition sound_editor.h:130
void handlePotentialParamMenuChange(deluge::hid::Button b, bool on, bool inCardRoutine, MenuItem *previousItem, MenuItem *currentItem)
Definition sound_editor.cpp:572
void endScreen()
end current menu item session before beginning new menu item session or exiting the sound editor
Definition sound_editor.cpp:854
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:709
Definition sound.h:71
Definition source.h:31
Definition horizontal_menu.h:28
Definition submenu.h:28