Deluge Firmware 1.3.0
Build date: 2025.04.16
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;
48namespace deluge::gui::menu_item {
49enum class RangeEdit : uint8_t;
50}
51
52class SoundEditor final : public UI {
53public:
54 SoundEditor();
55 bool opened() override;
56 void focusRegained() override;
57 void displayOrLanguageChanged() final;
58 bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) override;
59 Sound* currentSound;
60 bool allowsNoteTails;
61 ModControllableAudio* currentModControllable;
62 int8_t currentSourceIndex;
63 Source* currentSource;
64 ParamManagerForTimeline* currentParamManager;
65 SideChain* currentSidechain;
66 ArpeggiatorSettings* currentArpSettings;
67 ::MultiRange* currentMultiRange;
68 SampleControls* currentSampleControls;
69 VoicePriority* currentPriority;
70 int16_t currentMultiRangeIndex;
71 MIDICable* currentMIDICable;
72 deluge::gui::menu_item::RangeEdit editingRangeEdge;
73
74 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
75 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
76 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
77 void modEncoderAction(int32_t whichModEncoder, int32_t offset) override;
78 void modEncoderButtonAction(uint8_t whichModEncoder, bool on) override;
79 ActionResult horizontalEncoderAction(int32_t offset) override;
80 void scrollFinished() override;
81 bool editingKit();
82 bool editingKitAffectEntire();
83 bool editingKitRow();
84
85 ActionResult timerCallback() override;
86 void setupShortcutBlink(int32_t x, int32_t y, int32_t frequency);
87 bool findPatchedParam(int32_t paramLookingFor, int32_t* xout, int32_t* yout);
88 void updateSourceBlinks(MenuItem* currentItem);
89 void resetSourceBlinks();
90
91 uint8_t navigationDepth;
92 uint8_t patchingParamSelected;
93 uint8_t currentParamShorcutX;
94 uint8_t currentParamShorcutY;
95 uint8_t paramShortcutBlinkFrequency;
96 uint32_t shortcutBlinkCounter;
97
98 uint32_t timeLastAttemptedAutomatedParamEdit;
99
100 int8_t numberScrollAmount;
101 uint32_t numberEditSize;
102 int8_t numberEditPos;
103
104 uint8_t shortcutsVersion;
105
106 MenuItem* menuItemNavigationRecord[16];
107
108 bool shouldGoUpOneLevelOnBegin;
109
110 bool programChangeReceived(MIDICable& cable, uint8_t channel, uint8_t program) { return false; }
111 bool midiCCReceived(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value);
112 bool pitchBendReceived(MIDICable& cable, uint8_t channel, uint8_t data1, uint8_t data2);
113 void selectEncoderAction(int8_t offset) override;
114 bool canSeeViewUnderneath() override { return true; }
115 bool setup(Clip* clip = nullptr, const MenuItem* item = nullptr, int32_t sourceIndex = 0);
116 void enterOrUpdateSoundEditor(bool on);
117 void blinkShortcut();
118 ActionResult potentialShortcutPadAction(int32_t x, int32_t y, bool on);
119 bool editingReverbSidechain();
120 MenuItem* getCurrentMenuItem();
121 bool inSettingsMenu();
122 bool setupKitGlobalFXMenu;
123 bool exitUI() override {
124 exitCompletely();
125 return true;
126 };
127 void exitCompletely();
128 void goUpOneLevel();
129 void enterSubmenu(MenuItem* newItem);
130 bool pcReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t program) override;
131 bool noteOnReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t note, int32_t velocity) override;
132 void markInstrumentAsEdited();
133 bool editingCVOrMIDIClip();
134 bool editingNonAudioDrumRow();
135 bool editingMidiDrumRow();
136 bool editingGateDrumRow();
137 bool isUntransposedNoteWithinRange(int32_t noteCode);
138 void setCurrentMultiRange(int32_t i);
139 void possibleChangeToCurrentRangeDisplay();
140 MenuPermission checkPermissionToBeginSessionForRangeSpecificParam(Sound* sound, int32_t whichThing,
141 ::MultiRange** previouslySelectedRange);
142 void setupExclusiveShortcutBlink(int32_t x, int32_t y);
143 void setShortcutsVersion(int32_t newVersion);
144 ModelStackWithThreeMainThings* getCurrentModelStack(void* memory);
145
146 void cutSound();
147 AudioFileHolder* getCurrentAudioFileHolder();
148 void mpeZonesPotentiallyUpdated();
149
150 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
151
152 // ui
153 UIType getUIType() override { return UIType::SOUND_EDITOR; }
154
155 bool selectedNoteRow;
156
157 // Note / Note Row Editor
158 bool inNoteEditor();
159 bool inNoteRowEditor();
160 void toggleNoteEditorParamMenu(int32_t on);
161 void updatePadLightsFor(MenuItem* item);
162
163private:
165 void setupShortcutsBlinkFromTable(MenuItem const* currentItem,
166 MenuItem const* const items[kDisplayWidth][kDisplayHeight]);
167 bool beginScreen(MenuItem* oldMenuItem = nullptr);
168 uint8_t getActualParamFromScreen(uint8_t screen);
169 void setLedStates();
170 ActionResult handleAutomationViewPadAction(int32_t x, int32_t y, int32_t velocity);
171 bool isEditingAutomationViewParam();
172 void handlePotentialParamMenuChange(deluge::hid::Button b, bool on, bool inCardRoutine, MenuItem* previousItem,
173 MenuItem* currentItem);
174 bool handleClipName();
175
176 uint8_t sourceShortcutBlinkFrequencies[2][kDisplayHeight];
177 uint8_t sourceShortcutBlinkColours[2][kDisplayHeight];
178};
179
180extern SoundEditor soundEditor;
Definition arpeggiator.h:46
Definition arpeggiator.h:310
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:94
Base class for all menu items.
Definition menu_item.h:39
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:52
bool exitUI() override
returns whether a UI exited
Definition sound_editor.h:123
void handlePotentialParamMenuChange(deluge::hid::Button b, bool on, bool inCardRoutine, MenuItem *previousItem, MenuItem *currentItem)
Definition sound_editor.cpp:540
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:649
Definition sound.h:71
Definition source.h:31