Deluge Firmware 1.3.0
Build date: 2025.06.05
Loading...
Searching...
No Matches
performance_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_navigation_timeline_view.h"
22#include "hid/button.h"
23#include "modulation/params/param.h"
24#include "storage/storage_manager.h"
25
26class Editor;
27class InstrumentClip;
28class Clip;
29class ModelStack;
32
33struct PadPress {
34 bool isActive;
35 int32_t xDisplay;
36 int32_t yDisplay;
38 int32_t paramID;
39};
40
42 int32_t previousKnobPosition;
43 int32_t currentKnobPosition;
44 int32_t yDisplay;
45 uint32_t timeLastPadPress;
46 bool padPressHeld;
47};
48
50 deluge::modulation::params::Kind paramKind = deluge::modulation::params::Kind::NONE;
52 int32_t xDisplay = kNoSelection;
53 int32_t yDisplay = kNoSelection;
54 RGB rowColour = deluge::gui::colours::black;
55 RGB rowTailColour = deluge::gui::colours::black;
56};
57
58class PerformanceView final : public ClipNavigationTimelineView {
59public:
60 PerformanceView();
61 bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) override;
62 bool opened() override;
63 void focusRegained() override;
64
65 void graphicsRoutine() override;
66 ActionResult timerCallback() override;
67
68 // ui
69 UIType getUIType() override { return UIType::PERFORMANCE; }
70 UIType getUIContextType() override;
71 UIModControllableContext getUIModControllableContext() override { return UIModControllableContext::SONG; }
72 [[nodiscard]] int32_t getNavSysId() const override;
73
74 // rendering
75 bool renderMainPads(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
76 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], bool drawUndefinedArea = true) override;
77 bool renderSidebar(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
78 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth]) override;
79 void renderViewDisplay();
80 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
81 // 7SEG only
82 void redrawNumericDisplay();
83 void setLedStates();
84
85 // button action
86 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
87
88 // pad action
89 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
90
91 // horizontal encoder action
92 ActionResult horizontalEncoderAction(int32_t offset) override;
93
94 // vertical encoder action
95 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
96
97 // mod encoder action
98 void modEncoderAction(int32_t whichModEncoder, int32_t offset) override;
99 void modEncoderButtonAction(uint8_t whichModEncoder, bool on) override;
100 void modButtonAction(uint8_t whichButton, bool on) override;
101
102 // select encoder action
103 void selectEncoderAction(int8_t offset) override;
104
105 // not sure why we need these...
106 uint32_t getMaxZoom() override;
107 uint32_t getMaxLength() override;
108
109 // public so soundEditor can access it
114 bool defaultEditingMode;
115 bool editingParam; // if you're not editing a param, you're editing a value
116 bool justExitedSoundEditor;
117
118 // public so Action Logger can access it
119 FXColumnPress fxPress[kDisplayWidth];
120
121 // public so view.modEncoderAction and midi follow can access it
122 PadPress lastPadPress;
123 void renderFXDisplay(deluge::modulation::params::Kind paramKind, int32_t paramID, int32_t knobPos = kNoSelection);
124 bool onFXDisplay;
125
126 uint32_t timeKeyboardShortcutPress;
127
128 // public so mod controllable audio and midi follow can access it
129 bool possiblyRefreshPerformanceViewDisplay(deluge::modulation::params::Kind kind, int32_t id, int32_t newKnobPos);
130
131private:
132 // initialize
133 void initPadPress(PadPress& padPress);
134 void initFXPress(FXColumnPress& columnPress);
135 void initLayout(ParamsForPerformance& layout);
136 void initDefaultFXValues(int32_t xDisplay);
137
138 // rendering
139 void renderRow(RGB* image, int32_t yDisplay);
140 bool isParamAssignedToFXColumn(deluge::modulation::params::Kind paramKind, int32_t paramID);
141 void setCentralLEDStates();
142
143 // pad action
144 void normalPadAction(ModelStackWithThreeMainThings* modelStack, int32_t xDisplay, int32_t yDisplay, int32_t on);
145 void paramEditorPadAction(ModelStackWithThreeMainThings* modelStack, int32_t xDisplay, int32_t yDisplay,
146 int32_t on);
147 bool isPadShortcut(int32_t xDisplay, int32_t yDisplay);
149 int32_t paramID, int32_t xDisplay, int32_t knobPos, bool renderDisplay = true);
151 int32_t paramID, int32_t xDisplay, bool renderDisplay = true);
152 void padPressAction(ModelStackWithThreeMainThings* modelStack, deluge::modulation::params::Kind paramKind,
153 int32_t paramID, int32_t xDisplay, int32_t yDisplay, bool renderDisplay = true);
154 void padReleaseAction(ModelStackWithThreeMainThings* modelStack, deluge::modulation::params::Kind paramKind,
155 int32_t paramID, int32_t xDisplay, bool renderDisplay = true);
156 void resetFXColumn(ModelStackWithThreeMainThings* modelStack, int32_t xDisplay);
158 void resetPadPressInfo();
160
162 void writeDefaultsToFile();
164 void writeDefaultFXParamToFile(Serializer& writer, int32_t xDisplay);
165 void writeDefaultFXRowValuesToFile(Serializer& writer, int32_t xDisplay);
166 void writeDefaultFXHoldStatusToFile(Serializer& writer, int32_t xDisplay);
167 void loadDefaultLayout();
170 void readDefaultFXValuesFromFile();
171 void readDefaultFXParamAndRowValuesFromFile(int32_t xDisplay);
172 void readDefaultFXParamFromFile(int32_t xDisplay);
173 void readDefaultFXRowNumberValuesFromFile(int32_t xDisplay);
174 void readDefaultFXHoldStatusFromFile(int32_t xDisplay);
175 void initializeHeldFX(int32_t xDisplay);
176 bool successfullyReadDefaultsFromFile;
177 bool anyChangesToSave;
178
183 ParamsForPerformance backupXMLDefaultLayoutForPerformance[kDisplayWidth];
184 int32_t backupXMLDefaultFXValues[kDisplayWidth][kDisplayHeight];
185
186 int32_t getKnobPosForSinglePadPress(int32_t xDisplay, int32_t yDisplay);
187 int32_t calculateKnobPosForSelectEncoderTurn(int32_t knobPos, int32_t offset);
188
189 PadPress firstPadPress;
190 ParamsForPerformance layoutForPerformance[kDisplayWidth];
191 int32_t defaultFXValues[kDisplayWidth][kDisplayHeight];
192 int32_t layoutBank; // A or B (assign a layout to the bank for cross fader action)
193 int32_t layoutVariant; // 1, 2, 3, 4, 5 (1 = Load, 2 = Synth, 3 = Kit, 4 = Midi, 5 = CV)
194
195 // backup current layout
197 bool performanceLayoutBackedUp;
198 bool shouldRestorePreviousHoldPress(int32_t xDisplay);
199 void restorePreviousHoldPress(int32_t xDisplay);
200 void logPerformanceViewPress(int32_t xDisplay, bool closeAction = true);
201 bool anyChangesToLog();
202 FXColumnPress backupFXPress[kDisplayWidth];
203
204 // Members regarding rendering different layouts
205private:
206 bool sessionButtonActive = false;
207 bool sessionButtonUsed = false;
208};
209
210extern PerformanceView performanceView;
Definition clip.h:46
Definition instrument_clip.h:48
Definition model_stack.h:269
Definition model_stack.h:231
Definition model_stack.h:123
Definition performance_view.h:58
UIType getUIType() override
What type of UI is this? e.g. UIType::ARRANGER.
Definition performance_view.h:69
void renderViewDisplay()
Definition performance_view.cpp:486
void writeDefaultFXValuesToFile(Serializer &writer)
Definition performance_view.cpp:1742
void readDefaultsFromFile()
read defaults from XML
Definition performance_view.cpp:1858
void renderRow(RGB *image, int32_t yDisplay)
render every column, one row at a time
Definition performance_view.cpp:394
void writeDefaultsToFile()
write/load default values
Definition performance_view.cpp:1713
UIType getUIContextType() override
What context does UI relate to? e.g. UIType could be AUTOMATION but UIContextType could be ARRANGER,...
Definition performance_view.cpp:301
void resetPerformanceView(ModelStackWithThreeMainThings *modelStack)
Definition performance_view.cpp:1342
void modEncoderButtonAction(uint8_t whichModEncoder, bool on) override
used to reset stutter if it's already active
Definition performance_view.cpp:1618
void normalPadAction(ModelStackWithThreeMainThings *modelStack, int32_t xDisplay, int32_t yDisplay, int32_t on)
process pad actions in the normal performance view or value editor
Definition performance_view.cpp:1081
void releaseViewOnExit(ModelStackWithThreeMainThings *modelStack)
Definition performance_view.cpp:1380
void getParameterValue(ModelStackWithThreeMainThings *modelStack, deluge::modulation::params::Kind paramKind, int32_t paramID, int32_t xDisplay, bool renderDisplay=true)
Definition performance_view.cpp:1464
FXColumnPress backupXMLDefaultFXPress[kDisplayWidth]
Definition performance_view.h:182
void resetFXColumn(ModelStackWithThreeMainThings *modelStack, int32_t xDisplay)
Definition performance_view.cpp:1365
void savePerformanceViewLayout()
update saved perfomance view layout and update saved changes status
Definition performance_view.cpp:1706
void writeDefaultFXParamToFile(Serializer &writer, int32_t xDisplay)
convert paramID to a paramName to write to XML
Definition performance_view.cpp:1758
void readDefaultsFromBackedUpFile()
re-read defaults from backed up XML in memory in order to reduce SD Card IO
Definition performance_view.cpp:1842
void updateLayoutChangeStatus()
Definition performance_view.cpp:1659
void loadPerformanceViewLayout()
backup current layout, load saved layout, log layout change, update change status
Definition performance_view.cpp:1824
uint32_t getMaxZoom() override
why do I need this? (code won't compile without it)
Definition performance_view.cpp:1587
void writeDefaultFXHoldStatusToFile(Serializer &writer, int32_t xDisplay)
Definition performance_view.cpp:1794
void releaseStutter(ModelStackWithThreeMainThings *modelStack)
check if stutter is active and release it if it is
Definition performance_view.cpp:1394
bool anyChangesToLog()
check if there are any changes that needed to be logged in action logger for undo/redo mechanism to w...
Definition performance_view.cpp:1316
void modEncoderAction(int32_t whichModEncoder, int32_t offset) override
Definition performance_view.cpp:1598
void resetPadPressInfo()
initialize pad press info structs
Definition performance_view.cpp:1388
bool isParamAssignedToFXColumn(deluge::modulation::params::Kind paramKind, int32_t paramID)
check if a param has been assinged to any of the FX columns
Definition performance_view.cpp:452
void writeDefaultFXRowValuesToFile(Serializer &writer, int32_t xDisplay)
Definition performance_view.cpp:1777
uint32_t getMaxLength() override
why do I need this? (code won't compile without it)
Definition performance_view.cpp:1592
void restorePreviousHoldPress(int32_t xDisplay)
re-load performance layout column press info from backup
Definition performance_view.cpp:1295
bool isPadShortcut(int32_t xDisplay, int32_t yDisplay)
check if pad press corresponds to a shortcut pad on the grid
Definition performance_view.cpp:1276
void paramEditorPadAction(ModelStackWithThreeMainThings *modelStack, int32_t xDisplay, int32_t yDisplay, int32_t on)
process pad actions in the param editor
Definition performance_view.cpp:1213
void loadDefaultLayout()
if no XML file exists, load default layout (paramKind, paramID, xDisplay, yDisplay,...
Definition performance_view.cpp:1907
void renderFXDisplay(deluge::modulation::params::Kind paramKind, int32_t paramID, int32_t knobPos=kNoSelection)
Render Parameter Name and Value set when using Performance Pads.
Definition performance_view.cpp:562
void logPerformanceViewPress(int32_t xDisplay, bool closeAction=true)
Definition performance_view.cpp:1306
bool setParameterValue(ModelStackWithThreeMainThings *modelStack, deluge::modulation::params::Kind paramKind, int32_t paramID, int32_t xDisplay, int32_t knobPos, bool renderDisplay=true)
Definition performance_view.cpp:1407
void selectEncoderAction(int8_t offset) override
Used to edit a pad's value in editing mode.
Definition performance_view.cpp:1521
int32_t getKnobPosForSinglePadPress(int32_t xDisplay, int32_t yDisplay)
Definition performance_view.cpp:1499
int32_t calculateKnobPosForSelectEncoderTurn(int32_t knobPos, int32_t offset)
used to calculate new knobPos when you turn the select encoder
Definition performance_view.cpp:1547
void backupPerformanceLayout()
backup performance layout column press info so changes can be undone / redone later
Definition performance_view.cpp:1285
UIModControllableContext getUIModControllableContext() override
What mod controllable context is this UI using? E.g. Automation View can use the Song ModControllable...
Definition performance_view.h:71
void readDefaultFXParamFromFile(int32_t xDisplay)
Definition performance_view.cpp:1970
bool renderSidebar(uint32_t whichRows, RGB image[][kDisplayWidth+kSideBarWidth], uint8_t occupancyMask[][kDisplayWidth+kSideBarWidth]) override
if entered performance view using pink grid mode pad, render the pink pad
Definition performance_view.cpp:463
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition storage_manager.h:119
uint8_t ParamType
Definition param.h:65
Kind
Definition param.h:42
Definition performance_view.h:41
Definition performance_view.h:33
Definition performance_view.h:49