Deluge Firmware 1.3.0
Build date: 2025.09.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 renderDisplay(int32_t knobPosLeft = kNoSelection, int32_t knobPosRight = kNoSelection,
88 bool modEncoderAction = false);
89 void displayAutomation(bool padSelected = false, bool updateDisplay = true);
90
91 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override {
92 InstrumentClipMinder::renderOLED(canvas);
93 }
94
95 // button action
96 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
97
98 // pad action
99 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
100
101 // horizontal encoder action
102 ActionResult horizontalEncoderAction(int32_t offset) override;
103 uint32_t getMaxLength() override;
104 uint32_t getMaxZoom() override;
105 [[nodiscard]] int32_t getNavSysId() const override;
106 int32_t navSysId;
107
108 // vertical encoder action
109 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
110 void potentiallyVerticalScrollToSelectedDrum(InstrumentClip* clip, Output* output);
111
112 // mod encoder action
113 void modEncoderAction(int32_t whichModEncoder, int32_t offset) override;
114 void modEncoderButtonAction(uint8_t whichModEncoder, bool on) override;
115 CopiedParamAutomation copiedParamAutomation;
116
117 // Select encoder action
118 void selectEncoderAction(int8_t offset) override;
119 void getLastSelectedParamShortcut(Clip* clip); // public so menu can access it
120 void getLastSelectedParamArrayPosition(Clip* clip); // public so menu can access it
121 bool multiPadPressSelected; // public so menu can access it
122
123 // called by melodic_instrument.cpp or kit.cpp
124 void noteRowChanged(InstrumentClip* clip, NoteRow* noteRow) override;
125
126 // called by playback_handler.cpp
127 void notifyPlaybackBegun() override;
128
129 bool interpolation;
130 bool interpolationBefore;
131 bool interpolationAfter;
132
133 // public to midi follow and editor layouts can access it
134 ModelStackWithAutoParam*
135 getModelStackWithParamForClip(ModelStackWithTimelineCounter* modelStack, Clip* clip,
137 deluge::modulation::params::Kind paramKind = deluge::modulation::params::Kind::NONE);
138
139 // public so instrument clip view can access it
140 void initParameterSelection(bool updateDisplay = true);
141 bool onArrangerView;
142
143 // public so uiTimerManager and editor layouts can access it
144 void blinkInterpolationShortcut();
145 void blinkPadSelectionShortcut();
146
147 // public so menu and editor layouts can access it
148 bool onMenuView;
149 UI* previousUI; // previous UI so you can swap back UI after exiting menu
150 int32_t getAutomationParameterKnobPos(ModelStackWithAutoParam* modelStack, uint32_t pos);
151 void setAutomationKnobIndicatorLevels(ModelStackWithAutoParam* modelStack, int32_t knobPosLeft,
152 int32_t knobPosRight);
153 void initInterpolation();
154 void resetInterpolationShortcutBlinking();
155 void initPadSelection();
156 void resetPadSelectionShortcutBlinking();
157
158 AutomationParamType automationParamType;
159 bool getAffectEntire() override;
160
161 // public so action logger can access it
162 void resetShortcutBlinking();
163
164 bool padSelectionOn;
165 bool multiPadPressActive;
166 bool middlePadPressSelected;
167 int32_t leftPadSelectedX;
168 int32_t leftPadSelectedY;
169 int32_t rightPadSelectedX;
170 int32_t rightPadSelectedY;
171 int32_t lastPadSelectedKnobPos;
172
173private:
174 // button action functions
175 void handleSessionButtonAction(Clip* clip, bool on);
176 void handleKeyboardButtonAction(bool on);
177 void handleClipButtonAction(bool on, bool isAudioClip);
178 void handleCrossScreenButtonAction(bool on);
179 void handleKitButtonAction(OutputType outputType, bool on);
180 void handleSynthButtonAction(OutputType outputType, bool on);
181 void handleMidiButtonAction(OutputType outputType, bool on);
182 void handleCVButtonAction(OutputType outputType, bool on);
183 bool handleHorizontalEncoderButtonAction(bool on, bool isAudioClip);
184 bool handleBackAndHorizontalEncoderButtonComboAction(Clip* clip, bool on);
185 void handleVerticalEncoderButtonAction(bool on);
186 void handleSelectEncoderButtonAction(bool on);
187 void handleAffectEntireButtonAction(bool on);
188
189 // edit pad action
190 ActionResult handleEditPadAction(ModelStackWithAutoParam* modelStackWithParam,
191 ModelStackWithNoteRow* modelStackWithNoteRow, NoteRow* noteRow, Clip* clip,
192 Output* output, OutputType outputType, int32_t effectiveLength, int32_t x,
193 int32_t y, int32_t velocity, SquareInfo& squareInfo);
194 bool shortcutPadAction(ModelStackWithAutoParam* modelStackWithParam, Clip* clip, Output* output,
195 OutputType outputType, int32_t effectiveLength, int32_t x, int32_t y, int32_t velocity,
196 int32_t xScroll, int32_t xZoom, SquareInfo& squareInfo);
197 void handleParameterSelection(Clip* clip, Output* output, OutputType outputType, int32_t xDisplay,
198 int32_t yDisplay);
199 // mute pad action
200 ActionResult handleMutePadAction(ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
201 InstrumentClip* instrumentClip, Output* output, OutputType outputType, int32_t y,
202 int32_t velocity);
203
204 // audition pad action
205 ActionResult handleAuditionPadAction(InstrumentClip* instrumentClip, Output* output, OutputType outputType,
206 int32_t y, int32_t velocity);
207 ActionResult auditionPadAction(InstrumentClip* clip, Output* output, OutputType outputType, int32_t yDisplay,
208 int32_t velocity, bool shiftButtonDown);
209
210 // Automation View Render Functions
211 void performActualRender(RGB image[][kDisplayWidth + kSideBarWidth],
212 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], int32_t xScroll, uint32_t xZoom,
213 int32_t renderWidth, int32_t imageWidth, bool drawUndefinedArea = true);
214 void renderAutomationOverview(ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
215 ModelStackWithThreeMainThings* modelStackWithThreeMainThings, Clip* clip,
216 OutputType outputType, RGB image[][kDisplayWidth + kSideBarWidth],
217 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], int32_t xDisplay,
218 bool isMIDICVDrum);
219 void renderDisplayOLED(Clip* clip, Output* output, OutputType outputType, int32_t knobPosLeft = kNoSelection,
220 int32_t knobPosRight = kNoSelection);
221 void renderAutomationOverviewDisplayOLED(deluge::hid::display::oled_canvas::Canvas& canvas, Output* output,
222 OutputType outputType);
223 void renderDisplay7SEG(Clip* clip, Output* output, OutputType outputType, int32_t knobPosLeft = kNoSelection,
224 bool modEncoderAction = false);
225 void renderAutomationOverviewDisplay7SEG(Output* output, OutputType outputType);
226
227 // Horizontal Encoder Action
228 void shiftAutomationHorizontally(ModelStackWithAutoParam* modelStackWithParam, int32_t offset,
229 int32_t effectiveLength);
230
231 // Select Encoder Action
232 void selectGlobalParam(int32_t offset, Clip* clip);
233 void selectNonGlobalParam(int32_t offset, Clip* clip);
234 bool selectPatchCable(int32_t offset, Clip* clip);
235 bool selectPatchCableAtIndex(Clip* clip, PatchCableSet* set, int32_t patchCableIndex, bool& foundCurrentPatchCable);
236 void selectMIDICC(int32_t offset, Clip* clip);
237 int32_t getNextSelectedParamArrayPosition(int32_t offset, int32_t lastSelectedParamArrayPosition,
238 int32_t numParams);
239 void getLastSelectedNonGlobalParamArrayPosition(Clip* clip);
240 void getLastSelectedGlobalParamArrayPosition(Clip* clip);
241
242 void blinkShortcuts();
243 void resetParameterShortcutBlinking();
244 bool parameterShortcutBlinking;
245 bool interpolationShortcutBlinking;
246 bool padSelectionShortcutBlinking;
247
248 int32_t getEffectiveLength(ModelStackWithTimelineCounter* modelStack);
249
250 // grid sized array to assign midi cc values to each pad on the grid
251 void initMIDICCShortcutsForAutomation();
252 uint32_t midiCCShortcutsForAutomation[kDisplayWidth][kDisplayHeight];
253 bool midiCCShortcutsLoaded;
254
255 bool probabilityChanged;
256 uint32_t timeSelectKnobLastReleased;
257};
258
259extern AutomationView automationView;
Definition action.h:75
Definition audio_clip.h:35
Definition automation_view.h:50
void potentiallyVerticalScrollToSelectedDrum(InstrumentClip *clip, Output *output)
Definition automation_view.cpp:2385
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:1803
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:47
Definition instrument.h:44
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:98
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:298