Deluge Firmware 1.3.0
Build date: 2026.07.29
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 UI;
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};
76
77extern EnumStringMap<ActionType, 28> actionTypeMap;
78
79class Action {
80public:
81 Action(ActionType newActionType);
82 void addConsequence(Consequence* consequence);
83 Error revert(TimeType time, ModelStack* modelStack);
84 bool containsConsequenceParamChange(ParamCollection* paramCollection, int32_t paramId);
85 void recordParamChangeIfNotAlreadySnapshotted(ModelStackWithAutoParam const* modelStack, bool stealData = false);
86 void recordParamChangeDefinitely(ModelStackWithAutoParam const* modelStack, bool stealData);
87 Error recordNoteArrayChangeIfNotAlreadySnapshotted(InstrumentClip* clip, int32_t noteRowId, NoteVector* noteVector,
88 bool stealData, bool moveToFrontIfAlreadySnapshotted = false);
89 Error recordNoteArrayChangeDefinitely(InstrumentClip* clip, int32_t noteRowId, NoteVector* noteVector,
90 bool stealData);
91 bool containsConsequenceNoteArrayChange(InstrumentClip* clip, int32_t noteRowId, bool moveToFrontIfFound = false);
92 void recordNoteExistenceChange(InstrumentClip* clip, int32_t noteRowId, Note* note, ExistenceChangeType type);
93 void recordNoteChange(InstrumentClip* clip, int32_t noteRowId, Note* note, int32_t lengthAfter,
94 int32_t velocityAfter, int32_t probabilityAfter);
95 void updateYScrollClipViewAfter(InstrumentClip* clip = nullptr);
96 void recordClipInstanceExistenceChange(Output* output, ClipInstance* clipInstance, ExistenceChangeType type);
97 void prepareForDestruction(int32_t whichQueueActionIn, Song* song);
98 void recordClipLengthChange(Clip* clip, int32_t oldLength);
99 bool recordClipExistenceChange(Song* song, ClipArray* clipArray, Clip* clip, ExistenceChangeType type);
100 void recordAudioClipSampleChange(AudioClip* clip);
101 void deleteAllConsequences(int32_t whichQueueActionIn, Song* song, bool destructing = false);
102
103 ActionType type;
104 bool openForAdditions;
105
106 // A bunch of snapshot-things here store their state both before or after the action - because the action could have
107 // changed these
108 int32_t xScrollClip[2];
109 int32_t yScrollSongView[2];
110 int32_t xZoomClip[2];
111
112 int32_t xScrollArranger[2];
113 int32_t yScrollArranger[2];
114 int32_t xZoomArranger[2];
115
116 NoteSet modeNotes[2];
117
118 // And a few more snapshot-things here only store one state - at the time of the action, because the action could
119 // not change these things
120 uint8_t modKnobModeSongView;
121 bool affectEntireSongView;
122
123 bool tripletsOn;
124 uint32_t tripletsLevel;
125
126 // bool inKeyboardView;
127
128 UI* view;
129
130 Clip* currentClip; // Watch out - this might get set to NULL
131
132 int32_t posToClearArrangementFrom;
133
134 Action* nextAction;
135 Consequence* firstConsequence;
136
137 // We store these kinds of consequences separately because we need to be able to search through them fast, when
138 // there may be a large number of other kinds of consequences. Also, these don't need re-ordering each time we
139 // revert
140 ConsequenceParamChange* firstParamConsequence;
141
142 ActionClipState* clipStates;
143
144 uint32_t creationTime;
145
146 int32_t numClipStates;
147
148 int8_t offset; // Recorded for the purpose of knowing when we can do those "partial undos"
149
150private:
151};
Definition action_clip_state.h:24
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 enum_to_string_map.hpp:12
Definition instrument_clip.h:48
Definition instrument.h:45
Definition model_stack.h:269
Definition model_stack.h:123
Definition note_set.h:20
Definition note_vector.h:26
Definition note.h:24
Definition output.h:81
Definition param_collection.h:39
Definition song.h:103
Definition sound.h:71
Definition ui.h:92