Deluge Firmware 1.3.0
Build date: 2026.07.12
Loading...
Searching...
No Matches
automation_view.h
1/*
2 * Copyright (c) 2023 Sean Ditny
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/views/clip_view.h"
22#include "hid/button.h"
23#include "model/clip/instrument_clip_minder.h"
24#include "model/mod_controllable/mod_controllable_audio.h"
25#include "model/note/note_row.h"
26#include "modulation/automation/copied_param_automation.h"
27
28class Action;
29class CopiedNoteRow;
30class Drum;
31class Editor;
32class AudioClip;
33class Instrument;
34class InstrumentClip;
35class MidiInstrument;
36class ModControllable;
41class Note;
42class NoteRow;
43class ParamCollection;
45class ParamNode;
46class PatchCableSet;
47class Sound;
48class SoundDrum;
49
50class AutomationView final : public ClipView, public InstrumentClipMinder {
51public:
52 AutomationView();
53 bool opened() override;
54 void initializeView();
55 void openedInBackground();
56 void focusRegained() override;
57
58 // called by ui_timer_manager - might need to revise this routine for automation clip view since it references notes
59 void graphicsRoutine() override;
60
61 // ui
62 UIType getUIType() override { return UIType::AUTOMATION; }
63 UIType getUIContextType() override;
64 UIModControllableContext getUIModControllableContext() override {
65 return getUIContextType() == UIType::ARRANGER ? UIModControllableContext::SONG : UIModControllableContext::CLIP;
66 }
67
68 // used to identify the UI as a clip UI or not.
69 ClipMinder* toClipMinder() override { return getUIContextType() == UIType::ARRANGER ? nullptr : this; }
70
71 void setAutomationParamType();
72
73 bool onAutomationOverview();
74 bool inAutomationEditor();
75 bool inNoteEditor();
76
77 // rendering
78 bool possiblyRefreshAutomationEditorGrid(Clip* clip, deluge::modulation::params::Kind paramKind, int32_t paramID);
79 bool renderMainPads(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
80 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], bool drawUndefinedArea = true) override;
81 void renderUndefinedArea(int32_t xScroll, uint32_t xZoom, int32_t lengthToDisplay,
82 RGB image[][kDisplayWidth + kSideBarWidth],
83 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], int32_t imageWidth,
84 TimelineView* timelineView, bool tripletsOnHere, int32_t xDisplay);
85 bool renderSidebar(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
86 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth]) override;
87 void clipNeedsReRendering(Clip* clip) override;
88 void renderDisplay(int32_t knobPosLeft = kNoSelection, int32_t knobPosRight = kNoSelection,
89 bool modEncoderAction = false);
90 void displayAutomation(bool padSelected = false, bool updateDisplay = true);
91
92 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override {
93 InstrumentClipMinder::renderOLED(canvas);
94 }
95
96 // button action
97 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
98
99 // pad action
100 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
101 ActionResult auditionPadAction(InstrumentClip* clip, Output* output, OutputType outputType, int32_t yDisplay,
102 int32_t velocity, bool shiftButtonDown);
103
104 // horizontal encoder action
105 ActionResult horizontalEncoderAction(int32_t offset) override;
106 uint32_t getMaxLength() override;
107 uint32_t getMaxZoom() override;
108 [[nodiscard]] int32_t getNavSysId() const override;
109 int32_t navSysId;
110
111 // vertical encoder action
112 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
113 void potentiallyVerticalScrollToSelectedDrum(InstrumentClip* clip, Output* output);
114
115 // mod encoder action
116 void modEncoderAction(int32_t whichModEncoder, int32_t offset) override;
117 void modEncoderButtonAction(uint8_t whichModEncoder, bool on) override;
118 CopiedParamAutomation copiedParamAutomation;
119
120 // Select encoder action
121 void selectEncoderAction(int8_t offset) override;
122 void getLastSelectedParamShortcut(Clip* clip); // public so menu can access it
123 void getLastSelectedParamArrayPosition(Clip* clip); // public so menu can access it
124 bool multiPadPressSelected; // public so menu can access it
125
126 // called by melodic_instrument.cpp or kit.cpp
127 void noteRowChanged(InstrumentClip* clip, NoteRow* noteRow) override;
128
129 // called by playback_handler.cpp
130 void notifyPlaybackBegun() override;
131
132 bool interpolation;
133 bool interpolationBefore;
134 bool interpolationAfter;
135
136 // public to midi follow and editor layouts can access it
137 ModelStackWithAutoParam*
138 getModelStackWithParamForClip(ModelStackWithTimelineCounter* modelStack, Clip* clip,
140 deluge::modulation::params::Kind paramKind = deluge::modulation::params::Kind::NONE);
141
142 // public so instrument clip view can access it
143 void initParameterSelection(bool updateDisplay = true);
144 bool onArrangerView;
145
146 // public so uiTimerManager and editor layouts can access it
147 void blinkInterpolationShortcut();
148 void blinkPadSelectionShortcut();
149
150 // public so menu and editor layouts can access it
151 bool onMenuView;
152 UI* previousUI; // previous UI so you can swap back UI after exiting menu
153 int32_t getAutomationParameterKnobPos(ModelStackWithAutoParam* modelStack, uint32_t pos);
154 void setAutomationKnobIndicatorLevels(ModelStackWithAutoParam* modelStack, int32_t knobPosLeft,
155 int32_t knobPosRight);
156 void initInterpolation();
157 void resetInterpolationShortcutBlinking();
158 void initPadSelection();
159 void resetPadSelectionShortcutBlinking();
160
161 AutomationParamType automationParamType;
162 bool getAffectEntire() override;
163
164 // public so action logger can access it
165 void resetShortcutBlinking();
166
167 bool padSelectionOn;
168 bool multiPadPressActive;
169 bool middlePadPressSelected;
170 int32_t leftPadSelectedX;
171 int32_t leftPadSelectedY;
172 int32_t rightPadSelectedX;
173 int32_t rightPadSelectedY;
174 int32_t lastPadSelectedKnobPos;
175
176 bool isNoteVelocityEditorShortcut(int32_t x, int32_t y);
177
178private:
179 // button action functions
180 void handleSessionButtonAction(Clip* clip, bool on);
181 void handleKeyboardButtonAction(bool on);
182 void handleClipButtonAction(bool on, bool isAudioClip);
183 void handleCrossScreenButtonAction(bool on);
184 void handleKitButtonAction(OutputType outputType, bool on);
185 void handleSynthButtonAction(OutputType outputType, bool on);
186 void handleMidiButtonAction(OutputType outputType, bool on);
187 void handleCVButtonAction(OutputType outputType, bool on);
188 bool handleHorizontalEncoderButtonAction(bool on, bool isAudioClip);
189 bool handleBackAndHorizontalEncoderButtonComboAction(Clip* clip, bool on);
190 void handleVerticalEncoderButtonAction(bool on);
191 void handleSelectEncoderButtonAction(bool on);
192 void handleAffectEntireButtonAction(bool on);
193
194 // edit pad action
195 ActionResult handleEditPadAction(ModelStackWithAutoParam* modelStackWithParam,
196 ModelStackWithNoteRow* modelStackWithNoteRow, NoteRow* noteRow, Clip* clip,
197 Output* output, OutputType outputType, int32_t effectiveLength, int32_t x,
198 int32_t y, int32_t velocity, SquareInfo& squareInfo);
199 bool shortcutPadAction(ModelStackWithAutoParam* modelStackWithParam, Clip* clip, Output* output,
200 OutputType outputType, int32_t effectiveLength, int32_t x, int32_t y, int32_t velocity,
201 int32_t xScroll, int32_t xZoom, SquareInfo& squareInfo);
202 void handleParameterSelection(Clip* clip, Output* output, OutputType outputType, int32_t xDisplay,
203 int32_t yDisplay);
204 // mute pad action
205 ActionResult handleMutePadAction(ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
206 InstrumentClip* instrumentClip, Output* output, OutputType outputType, int32_t y,
207 int32_t velocity);
208
209 // audition pad action
210 ActionResult handleAuditionPadAction(InstrumentClip* instrumentClip, Output* output, OutputType outputType,
211 int32_t y, int32_t velocity);
212
213 // Automation View Render Functions
214 void performActualRender(RGB image[][kDisplayWidth + kSideBarWidth],
215 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], int32_t xScroll, uint32_t xZoom,
216 int32_t renderWidth, int32_t imageWidth, bool drawUndefinedArea = true);
217 void renderAutomationOverview(ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
218 ModelStackWithThreeMainThings* modelStackWithThreeMainThings, Clip* clip,
219 OutputType outputType, RGB image[][kDisplayWidth + kSideBarWidth],
220 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], int32_t xDisplay,
221 bool isMIDICVDrum);
222 void renderDisplayOLED(Clip* clip, Output* output, OutputType outputType, int32_t knobPosLeft = kNoSelection,
223 int32_t knobPosRight = kNoSelection);
224 void renderAutomationOverviewDisplayOLED(deluge::hid::display::oled_canvas::Canvas& canvas, Output* output,
225 OutputType outputType);
226 void renderDisplay7SEG(Clip* clip, Output* output, OutputType outputType, int32_t knobPosLeft = kNoSelection,
227 bool modEncoderAction = false);
228 void renderAutomationOverviewDisplay7SEG(Output* output, OutputType outputType);
229
230 // Horizontal Encoder Action
231 void shiftAutomationHorizontally(ModelStackWithAutoParam* modelStackWithParam, int32_t offset,
232 int32_t effectiveLength);
233
234 // Select Encoder Action
235 void selectGlobalParam(int32_t offset, Clip* clip);
236 void selectNonGlobalParam(int32_t offset, Clip* clip);
237 bool selectPatchCable(int32_t offset, Clip* clip);
238 bool selectPatchCableAtIndex(Clip* clip, PatchCableSet* set, int32_t patchCableIndex, bool& foundCurrentPatchCable);
239 void selectMIDICC(int32_t offset, Clip* clip);
240 int32_t getNextSelectedParamArrayPosition(int32_t offset, int32_t lastSelectedParamArrayPosition,
241 int32_t numParams);
242 void getLastSelectedNonGlobalParamArrayPosition(Clip* clip);
243 void getLastSelectedGlobalParamArrayPosition(Clip* clip);
244
245 void blinkShortcuts();
246 void resetParameterShortcutBlinking();
247 bool parameterShortcutBlinking;
248 bool interpolationShortcutBlinking;
249 bool padSelectionShortcutBlinking;
250
251 int32_t getEffectiveLength(ModelStackWithTimelineCounter* modelStack);
252
253 // grid sized array to assign midi cc values to each pad on the grid
254 void initMIDICCShortcutsForAutomation();
255 uint32_t midiCCShortcutsForAutomation[kDisplayWidth][kDisplayHeight];
256 bool midiCCShortcutsLoaded;
257
258 bool probabilityChanged;
259 uint32_t timeSelectKnobLastReleased;
260};
261
262extern AutomationView automationView;
Definition action.h:79
Definition audio_clip.h:35
Definition automation_view.h:50
void potentiallyVerticalScrollToSelectedDrum(InstrumentClip *clip, Output *output)
Definition automation_view.cpp:2404
UIModControllableContext getUIModControllableContext() override
What mod controllable context is this UI using? E.g. Automation View can use the Song ModControllable...
Definition automation_view.h:64
bool shortcutPadAction(ModelStackWithAutoParam *modelStackWithParam, Clip *clip, Output *output, OutputType outputType, int32_t effectiveLength, int32_t x, int32_t y, int32_t velocity, int32_t xScroll, int32_t xZoom, SquareInfo &squareInfo)
Definition automation_view.cpp:1835
ClipMinder * toClipMinder() override
Definition automation_view.h:69
UIType getUIContextType() override
What context does UI relate to? e.g. UIType could be AUTOMATION but UIContextType could be ARRANGER,...
Definition automation_view.cpp:599
UIType getUIType() override
What type of UI is this? e.g. UIType::ARRANGER.
Definition automation_view.h:62
Definition clip_minder.h:23
Definition clip.h:46
Definition copied_note_row.h:23
Definition drum.h:44
Definition instrument_clip.h:48
Definition instrument.h:45
Definition mod_controllable.h:40
Definition model_stack.h:269
Definition model_stack.h:189
Definition model_stack.h:231
Definition model_stack.h:129
Definition note_row.h:99
Definition note.h:24
Definition param_collection.h:39
Definition param_manager.h:174
Definition param_node.h:23
Definition patch_cable_set.h:41
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition sound_drum.h:28
Definition sound.h:71
Definition timeline_view.h:27
Kind
Definition param.h:42
constexpr uint32_t kNoParamID
Magic number which represents an invalid or missing param type.
Definition param.h:304