Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
view.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/colour/colour.h"
22#include "hid/button.h"
23#include "model/model_stack.h"
24#include "modulation/params/param.h"
25#include "processing/audio_output.h"
26#include <cstdint>
27
28class InstrumentClip;
29class NoteRow;
30class UI;
31class ModControllable;
33class RootUI;
36class Drum;
37class Instrument;
38class TimelineCounter;
39class Clip;
40class Output;
41class AudioClip;
44class LearnedMIDI;
45class Kit;
46
47// A view is where the user can interact with the pads - song view, Clip view, automation view and keyboard view.
48// (Is that still a good description? This class is a bit of a mishmash of poorly organised code, sorry.)
49
51class View {
52public:
53 View();
54 void focusRegained();
55 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine);
56 void setTimeBaseScaleLedState();
57 void setLedStates();
58
59 void clipStatusMidiLearnPadPressed(bool on, Clip* whichLoopable);
60 void noteRowMuteMidiLearnPadPressed(bool on, NoteRow* whichNoteRow);
61 void endMidiLearnPressSession(MidiLearn newThingPressed = MidiLearn::NONE);
62 void noteOnReceivedForMidiLearn(MIDICable& cable, int32_t channel, int32_t note, int32_t velocity);
63 void pcReceivedForMIDILearn(MIDICable& cable, int32_t channel, int32_t pc) {}
64 void ccReceivedForMIDILearn(MIDICable& cable, int32_t channel, int32_t cc, int32_t value);
65 void drumMidiLearnPadPressed(bool on, Drum* drum, Kit* kit);
66 void instrumentMidiLearnPadPressed(bool on, Instrument* instrument);
67 void sectionMidiLearnPadPressed(bool on, uint8_t section);
68 void midiLearnFlash();
69 void setModLedStates();
70 int32_t getModKnobMode();
71 void modEncoderAction(int32_t whichModEncoder, int32_t offset);
72 void modEncoderButtonAction(uint8_t whichModEncoder, bool on);
73 void modButtonAction(uint8_t whichButton, bool on);
74 void setKnobIndicatorLevels();
75 void setKnobIndicatorLevel(uint8_t whichModEncoder);
76 int32_t convertPatchCableKnobPosToIndicatorLevel(int32_t knobPos);
77 void setActiveModControllableTimelineCounter(TimelineCounter* playPositionCounter,
78 bool shouldSendMidiFeedback = true);
79 void setActiveModControllableWithoutTimelineCounter(ModControllable* modControllable, ParamManager* paramManager);
80 void cycleThroughReverbPresets();
81 char const* getReverbPresetDisplayName(int32_t preset);
82 int32_t getCurrentReverbPreset();
83 void setModRegion(uint32_t pos = 0xFFFFFFFF, uint32_t length = 0, int32_t noteRowId = 0);
84 void notifyParamAutomationOccurred(ParamManager* paramManager, bool updateModLevels = true);
85 void displayAutomation();
86 void displayOutputName(Output* output, bool doBlink = true, Clip* clip = nullptr);
87 void instrumentChanged(ModelStackWithTimelineCounter* modelStack, Instrument* newInstrument);
88 void navigateThroughPresetsForInstrumentClip(int32_t offset, ModelStackWithTimelineCounter* modelStack,
89 bool doBlink = false);
90 void navigateThroughAudioOutputsForAudioClip(int32_t offset, AudioClip* clip, bool doBlink = false);
91 bool changeOutputType(OutputType newOutputType, ModelStackWithTimelineCounter* modelStack, bool doBlink = false);
92 void drawOutputNameFromDetails(OutputType outputType, int32_t slot, int32_t subSlot, char const* name,
93 bool isNameEmpty, bool editedByUser, bool doBlink, Clip* clip = nullptr);
94 void startMIDILearn();
95 void endMIDILearn();
96 [[nodiscard]] RGB getClipMuteSquareColour(Clip* clip, RGB thisColour, bool allowMIDIFlash = true);
97 ActionResult clipStatusPadAction(Clip* clip, bool on, int32_t yDisplayIfInSessionView = -1);
98 void flashPlayEnable();
99 void flashPlayDisable();
100 void flashPlayRoutine();
101
102 void activateMacro(uint32_t y);
103 Clip* findNextClipForOutput(Output* output);
104 bool renderMacros(int32_t column, uint32_t y, int32_t selectedMacro, RGB image[][kDisplayWidth + kSideBarWidth],
105 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth]);
106
107 // MIDI learn stuff
108 MidiLearn thingPressedForMidiLearn = MidiLearn::NONE;
109 bool deleteMidiCommandOnRelease;
110 bool midiLearnFlashOn;
111 bool shouldSaveSettingsAfterMidiLearn;
112
113 LearnedMIDI* learnedThing;
114 Instrument* instrumentPressedForMIDILearn;
115 Drum* drumPressedForMIDILearn;
116
117 // deceivingly this is used only while learning drums
118 Kit* kitPressedForMIDILearn;
119
120 ModelStackWithThreeMainThings activeModControllableModelStack;
121 uint8_t dummy[MODEL_STACK_MAX_SIZE - sizeof(ModelStackWithThreeMainThings)];
122
123 bool pendingParamAutomationUpdatesModLevels;
124
125 bool clipArmFlashOn;
126 bool blinkOn;
127
128 uint32_t timeSaveButtonPressed;
129
130 int32_t modNoteRowId;
131 uint32_t modPos;
132 // 0 if not currently editing a region / step / holding a note. If you're gonna refer to this, you absolutely have
133 // to first check that the TimelineCounter you're thinking of setting some automation on
134 // == activeModControllableTimelineCounter
135 uint32_t modLength;
136
137 int32_t calculateKnobPosForDisplay(deluge::modulation::params::Kind kind, int32_t paramID, int32_t knobPos);
138 void displayModEncoderValuePopup(deluge::modulation::params::Kind kind, int32_t paramID, int32_t newKnobPos,
139 PatchSource source1 = PatchSource::NONE, PatchSource source2 = PatchSource::NONE);
140 void potentiallyMakeItHarderToTurnKnob(int32_t whichModEncoder, ModelStackWithAutoParam* modelStackWithParam,
141 int32_t newKnobPos);
142 void sendMidiFollowFeedback(ModelStackWithAutoParam* modelStackWithParam = nullptr, int32_t knobPos = kNoSelection,
143 bool isAutomation = false);
144
145 // vu meter rendering
146 bool displayVUMeter;
147 bool potentiallyRenderVUMeter(RGB image[][kDisplayWidth + kSideBarWidth]);
148
149 void getParameterNameFromModEncoder(int32_t whichModEncoder, char* parameterName);
150
151 bool isClipContext();
152
153private:
154 void pretendModKnobsUntouchedForAWhile();
155 void instrumentBeenEdited();
156 void clearMelodicInstrumentMonoExpressionIfPossible();
157
158 // vu meter rendering
159 int32_t getMaxYDisplayForVUMeter(float level);
160 int32_t cachedMaxYDisplayForVUMeterL;
161 int32_t cachedMaxYDisplayForVUMeterR;
162 void renderVUMeter(int32_t maxYDisplay, int32_t xDisplay, RGB thisImage[][kDisplayWidth + kSideBarWidth]);
163 bool renderedVUMeter;
164
165 ModelStackWithAutoParam* getModelStackWithParam(int32_t whichModEncoder, bool& noteTailsAllowedBefore);
166};
167
168extern View view;
Definition audio_clip.h:35
Definition clip.h:46
Definition drum.h:44
Definition instrument_clip.h:48
Definition instrument.h:45
Definition kit.h:34
Definition learned_midi.h:30
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Definition melodic_instrument.h:30
Definition mod_controllable.h:40
Definition model_stack.h:269
Definition model_stack.h:231
Definition model_stack.h:129
Definition note_row.h:98
Definition output.h:81
Definition param_manager.h:174
Definition param_manager.h:45
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition root_ui.h:27
Definition timeline_counter.h:28
Definition ui.h:92
Assorted utilities for manging the user interface.
Definition view.h:51
int32_t convertPatchCableKnobPosToIndicatorLevel(int32_t knobPos)
Definition view.cpp:1330
bool potentiallyRenderVUMeter(RGB image[][kDisplayWidth+kSideBarWidth])
Definition view.cpp:1678
void renderVUMeter(int32_t maxYDisplay, int32_t xDisplay, RGB thisImage[][kDisplayWidth+kSideBarWidth])
render AudioEngine::approxRMSLevel as a VU meter on the grid
Definition view.cpp:1775
Kind
Definition param.h:42