Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
load_instrument_preset_ui.h
1/*
2 * Copyright © 2018-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/ui/load/load_ui.h"
22#include "hid/button.h"
23#include "model/instrument/kit.h"
24#include "model/note/note_row.h"
25#include "processing/sound/sound_drum.h"
26
27class Instrument;
28class InstrumentClip;
29class Output;
30
31class LoadInstrumentPresetUI final : public LoadUI {
32public:
33 LoadInstrumentPresetUI() = default;
34 bool opened() override;
35 // void selectEncoderAction(int8_t offset);
36 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
37 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
38 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
39 void instrumentEdited(Instrument* instrument);
40 Error performLoad(bool doClone = false);
41 Error performLoadSynthToKit();
42 ActionResult timerCallback() override;
43 bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) override;
44 bool renderMainPads(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth] = nullptr,
45 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth] = nullptr, bool drawUndefinedArea = true,
46 int32_t navSys = -1) {
47 return true;
48 }
49 bool renderSidebar(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
50 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth]) override;
51 std::expected<FileItem*, Error>
52 findAnUnlaunchedPresetIncludingWithinSubfolders(Song* song, OutputType outputType,
53 Availability availabilityRequirement);
54 std::expected<FileItem*, Error> confirmPresetOrNextUnlaunchedOne(OutputType outputType, String* searchName,
55 Availability availabilityRequirement);
56 PresetNavigationResult doPresetNavigation(int32_t offset, Instrument* oldInstrument,
57 Availability availabilityRequirement, bool doBlink);
58 void setupLoadInstrument(OutputType newOutputType, Instrument* instrumentToReplace_,
59 InstrumentClip* instrumentClipToLoadFor_) {
60 Browser::outputTypeToLoad = newOutputType;
61 instrumentToReplace = instrumentToReplace_;
62 instrumentClipToLoadFor = instrumentClipToLoadFor_;
63 loadingSynthToKitRow = false;
64 soundDrumToReplace = nullptr;
65 noteRowIndex = 255; // (not set value for note rows)
66 noteRow = nullptr;
67 }
68 void setupLoadSynthToKit(Instrument* kit, InstrumentClip* clip, SoundDrum* drum, NoteRow* row, int32_t rowIndex) {
69 Browser::outputTypeToLoad = OutputType::SYNTH;
70 instrumentToReplace = kit;
71 instrumentClipToLoadFor = clip;
72 loadingSynthToKitRow = true;
73 soundDrumToReplace = drum;
74 noteRowIndex = rowIndex; // (not set value for note rows)
75 noteRow = row;
76 }
77
78 // ui
79 UIType getUIType() override { return UIType::LOAD_INSTRUMENT_PRESET; }
80
81protected:
82 void enterKeyPress() override;
83 void folderContentsReady(int32_t entryDirection) override;
84 void currentFileChanged(int32_t movementDirection) override;
85
86private:
87 bool showingAuditionPads();
88 Error setupForOutputType();
89 void changeOutputType(OutputType newOutputType);
90 void revertToInitialPreset();
91 void exitAction() override;
92 bool isInstrumentInList(Instrument* searchInstrument, Output* list);
93 bool findUnusedSlotVariation(String* oldName, String* newName);
94
95 InstrumentClip* instrumentClipToLoadFor; // Can be NULL - if called from Arranger.
96 Instrument* instrumentToReplace; // The Instrument that's actually successfully loaded and assigned to the Clip.
97
98 // these are all necessary to setup a sound drum
99 bool loadingSynthToKitRow;
100 SoundDrum* soundDrumToReplace;
101 int32_t noteRowIndex;
102 NoteRow* noteRow;
103 Error currentInstrumentLoadError;
104
105 int16_t initialChannel;
106 int8_t initialChannelSuffix;
107 OutputType initialOutputType;
108
109 bool changedInstrumentForClip;
110 bool replacedWholeInstrument;
111
112 String initialName;
113 String initialDirPath;
114};
115
116extern LoadInstrumentPresetUI loadInstrumentPresetUI;
Definition instrument_clip.h:48
Definition instrument.h:45
Definition load_instrument_preset_ui.h:31
PresetNavigationResult doPresetNavigation(int32_t offset, Instrument *oldInstrument, Availability availabilityRequirement, bool doBlink)
Definition load_instrument_preset_ui.cpp:1411
Definition note_row.h:98
Definition output.h:81
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition song.h:104
Definition sound_drum.h:28
Definition d_string.h:46
Definition browser.h:42