Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
action.h
1/*
2 * Copyright © 2017-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 "model/scale/note_set.h"
22#include "util/container/enum_to_string_map.hpp"
23
24#include <cstdint>
25
26class Consequence;
27class InstrumentClip;
28class ParamCollection;
29class Sound;
30class AutoParam;
32class Note;
33class ActionClipState;
34class RootUI;
35class Instrument;
36class ClipInstance;
37class Song;
38class Output;
39class Clip;
40class ClipArray;
41class AudioClip;
42class NoteVector;
44class ModelStack;
45
46enum class ActionType {
47 MISC,
48 NOTE_EDIT,
49 NOTE_TAIL_EXTEND,
50 CLIP_LENGTH_INCREASE,
51 CLIP_LENGTH_DECREASE,
52 RECORD,
53 AUTOMATION_DELETE,
54 PARAM_UNAUTOMATED_VALUE_CHANGE,
55 SWING_CHANGE,
56 TEMPO_CHANGE,
57 CLIP_MULTIPLY,
58 CLIP_CLEAR,
59 CLIP_DELETE,
60 NOTES_PASTE,
61 PATTERN_PASTE,
62 AUTOMATION_PASTE,
63 CLIP_INSTANCE_EDIT,
64 ARRANGEMENT_TIME_EXPAND,
65 ARRANGEMENT_TIME_CONTRACT,
66 ARRANGEMENT_CLEAR,
67 ARRANGEMENT_RECORD,
68 CLIP_HORIZONTAL_SHIFT,
69 NOTE_NUDGE,
70 NOTE_REPEAT_EDIT,
71 EUCLIDEAN_NUM_EVENTS_EDIT,
72 NOTEROW_ROTATE,
73 NOTEROW_LENGTH_EDIT,
74 NOTEROW_HORIZONTAL_SHIFT,
75 SECTION_REORDER,
76};
77
78class Action {
79public:
80 Action(ActionType newActionType);
81 void addConsequence(Consequence* consequence);
82 Error revert(TimeType time, ModelStack* modelStack);
83 bool containsConsequenceParamChange(ParamCollection* paramCollection, int32_t paramId);
84 void recordParamChangeIfNotAlreadySnapshotted(ModelStackWithAutoParam const* modelStack, bool stealData = false);
85 void recordParamChangeDefinitely(ModelStackWithAutoParam const* modelStack, bool stealData);
86 Error recordNoteArrayChangeIfNotAlreadySnapshotted(InstrumentClip* clip, int32_t noteRowId, NoteVector* noteVector,
87 bool stealData, bool moveToFrontIfAlreadySnapshotted = false);
88 Error recordNoteArrayChangeDefinitely(InstrumentClip* clip, int32_t noteRowId, NoteVector* noteVector,
89 bool stealData);
90 bool containsConsequenceNoteArrayChange(InstrumentClip* clip, int32_t noteRowId, bool moveToFrontIfFound = false);
91 void recordNoteExistenceChange(InstrumentClip* clip, int32_t noteRowId, Note* note, ExistenceChangeType type);
92 void recordNoteChange(InstrumentClip* clip, int32_t noteRowId, Note* note, int32_t lengthAfter,
93 int32_t velocityAfter, int32_t probabilityAfter);
94 void updateYScrollClipViewAfter(InstrumentClip* clip = nullptr);
95 void recordClipInstanceExistenceChange(Output* output, ClipInstance* clipInstance, ExistenceChangeType type);
96 void prepareForDestruction(int32_t whichQueueActionIn, Song* song);
97 void recordClipLengthChange(Clip* clip, int32_t oldLength);
98 bool recordClipExistenceChange(Song* song, ClipArray* clipArray, Clip* clip, ExistenceChangeType type);
99 void recordAudioClipSampleChange(AudioClip* clip);
100 void deleteAllConsequences(int32_t whichQueueActionIn, Song* song, bool destructing = false);
101
102 ActionType type;
103 bool openForAdditions;
106 bool stale = false;
107
108 // A bunch of snapshot-things here store their state both before or after the action - because the action could have
109 // changed these
110 int32_t xScrollClip[2];
111 int32_t yScrollSongView[2];
112 int32_t xZoomClip[2];
113
114 int32_t xScrollArranger[2];
115 int32_t yScrollArranger[2];
116 int32_t xZoomArranger[2];
117
118 NoteSet modeNotes[2];
119
120 // And a few more snapshot-things here only store one state - at the time of the action, because the action could
121 // not change these things
122 uint8_t modKnobModeSongView;
123 bool affectEntireSongView;
124
125 bool tripletsOn;
126 uint32_t tripletsLevel;
127
128 // bool inKeyboardView;
129
130 // Grouping and navigation use the root view, including for edits made in an overlay.
131 RootUI* view;
132
133 Clip* currentClip; // Watch out - this might get set to NULL
134
135 int32_t posToClearArrangementFrom;
136
137 Action* nextAction;
138 Consequence* firstConsequence;
139
140 // We store these kinds of consequences separately because we need to be able to search through them fast, when
141 // there may be a large number of other kinds of consequences. Also, these don't need re-ordering each time we
142 // revert
143 ConsequenceParamChange* firstParamConsequence;
144
145 ActionClipState* clipStates;
146
147 uint32_t creationTime;
148
149 int32_t numClipStates;
150
151 int8_t offset; // Recorded for the purpose of knowing when we can do those "partial undos"
152
153private:
154};
Definition action_clip_state.h:24
bool stale
Definition action.h:106
Definition audio_clip.h:35
Definition auto_param.h:44
Definition clip_array.h:25
Definition clip_instance.h:29
Definition clip.h:46
Definition consequence_param_change.h:25
Definition consequence.h:27
Definition instrument_clip.h:52
Definition instrument.h:45
Definition model_stack.h:264
Definition model_stack.h:123
Definition note_set.h:20
Definition note_vector.h:27
Definition note.h:25
Definition output.h:81
Definition param_collection.h:39
Definition root_ui.h:27
Definition song.h:112
Definition sound.h:78