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