Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
param_manager.h
1/*
2 * Copyright © 2016-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 "modulation/params/param_collection_summary.h"
22#include <cstdint>
23
24class Song;
25class Sound;
26class ParamSet;
27class InstrumentClip;
28class Action;
29class ParamCollection;
30class TimelineCounter;
31class Output;
36class PatchCableSet;
38class PatchedParamSet;
42
43#define PARAM_COLLECTIONS_STORAGE_NUM 5
44
45class ParamManager {
46public:
47 ParamManager();
48 ~ParamManager();
49
50 // Not including MPE params
51 inline bool containsAnyMainParamCollections() { return expressionParamSetOffset; }
52
53 inline bool containsAnyParamCollectionsIncludingExpression() { return summaries[0].paramCollection; }
54
55 Error setupWithPatching();
56 Error setupUnpatched();
57 Error setupMIDI();
58
59 void stealParamCollectionsFrom(ParamManager* other, bool stealExpressionParams = false);
60 Error cloneParamCollectionsFrom(ParamManager const* other, bool copyAutomation, bool cloneExpressionParams = false,
61 int32_t reverseDirectionWithLength = 0);
62 Error beenCloned(int32_t reverseDirectionWithLength = 0); // Will clone Collections
63 void forgetParamCollections();
64 void destructAndForgetParamCollections();
65 bool ensureExpressionParamSetExists(bool forDrum = false);
66
67 inline int32_t getExpressionParamSetOffset() { return expressionParamSetOffset; }
68
69 ExpressionParamSet* getOrCreateExpressionParamSet(bool forDrum = false); // Will return NULL if can't create
70
71 inline ParamCollectionSummary* getExpressionParamSetSummary() { // Will return one containing NULL if didn't exist
72 return &summaries[getExpressionParamSetOffset()];
73 }
74
75 inline ExpressionParamSet* getExpressionParamSet() { // Will return NULL if didn't exist
76 return (ExpressionParamSet*)getExpressionParamSetSummary()->paramCollection;
77 }
78
79 inline MIDIParamCollection* getMIDIParamCollection() {
80#if ALPHA_OR_BETA_VERSION
81 if (!summaries[0].paramCollection) {
82 FREEZE_WITH_ERROR("E409");
83 }
84#endif
85 return (MIDIParamCollection*)summaries[0].paramCollection;
86 }
87
88 inline ParamCollectionSummary* getMIDIParamCollectionSummary() {
89#if ALPHA_OR_BETA_VERSION
90 if (!summaries[0].paramCollection) {
91 FREEZE_WITH_ERROR("E409");
92 }
93#endif
94 return &summaries[0];
95 }
96
97 inline UnpatchedParamSet* getUnpatchedParamSet() {
98#if ALPHA_OR_BETA_VERSION
99 if (!summaries[0].paramCollection) {
100 FREEZE_WITH_ERROR("E410");
101 }
102#endif
103 return (UnpatchedParamSet*)summaries[0].paramCollection;
104 }
105
106 inline ParamCollectionSummary* getUnpatchedParamSetSummary() {
107#if ALPHA_OR_BETA_VERSION
108 if (!summaries[0].paramCollection) {
109 FREEZE_WITH_ERROR("E410");
110 }
111#endif
112 return &summaries[0];
113 }
114
115 inline PatchedParamSet* getPatchedParamSet() {
116#if ALPHA_OR_BETA_VERSION
117 if (!summaries[1].paramCollection) {
118 FREEZE_WITH_ERROR("E411");
119 }
120#endif
121 return (PatchedParamSet*)summaries[1].paramCollection;
122 }
123
124 inline ParamCollectionSummary* getPatchedParamSetSummary() {
125#if ALPHA_OR_BETA_VERSION
126 if (!summaries[1].paramCollection) {
127 FREEZE_WITH_ERROR("E411");
128 }
129#endif
130 return &summaries[1];
131 }
132
133 inline ParamCollectionSummary* getPatchCableSetSummary() {
134#if ALPHA_OR_BETA_VERSION
135 if (!summaries[2].paramCollection) {
136 FREEZE_WITH_ERROR("E412");
137 }
138#endif
139 return &summaries[2];
140 }
141
142 inline PatchCableSet* getPatchCableSet() {
143#if ALPHA_OR_BETA_VERSION
144 if (!summaries[2].paramCollection) {
145 FREEZE_WITH_ERROR("E412");
146 }
147#endif
148 return (PatchCableSet*)summaries[2].paramCollection;
149 }
150
151 ModelStackWithParamCollection* getPatchCableSet(ModelStackWithThreeMainThings const* modelStack);
152
153 inline PatchCableSet* getPatchCableSetAllowJibberish() { // Don't ask.
154 return (PatchCableSet*)summaries[2].paramCollection;
155 }
156
157 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t currentValueChanged,
158 bool automationChanged, bool paramAutomatedNow);
159
160#if ALPHA_OR_BETA_VERSION
161 virtual ParamManagerForTimeline* toForTimeline();
162#else
163 inline ParamManagerForTimeline* toForTimeline() { return (ParamManagerForTimeline*)this; }
164#endif
165
166 bool resonanceBackwardsCompatibilityProcessed;
167 uint8_t expressionParamSetOffset;
168
169 // This list should be terminated by an object whose values are all zero. Yes, all of them must be zero, because if
170 // we know this, we can check for stuff faster.
171 ParamCollectionSummary summaries[PARAM_COLLECTIONS_STORAGE_NUM];
172};
173
174class ParamManagerForTimeline final : public ParamManager { // I want to rename this one to "with automation"
175public:
176 ParamManagerForTimeline();
177
178 void tickSamples(int32_t numSamples, ModelStackWithThreeMainThings* modelStack);
179 void setPlayPos(uint32_t pos, ModelStackWithThreeMainThings* modelStack, bool reversed);
180 void expectNoFurtherTicks(ModelStackWithThreeMainThings* modelStack);
181 void grabValuesFromPos(uint32_t pos, ModelStackWithThreeMainThings* modelStack);
182 void generateRepeats(ModelStackWithThreeMainThings* modelStack, uint32_t oldLength, uint32_t newLength,
183 bool shouldPingpong);
184 void appendParamManager(ModelStackWithThreeMainThings* modelStack, ModelStackWithThreeMainThings* otherModelStack,
185 int32_t oldLength, int32_t reverseThisRepeatWithLength, bool pingpongingGenerally);
186 void trimToLength(uint32_t newLength, ModelStackWithThreeMainThings* modelStack, Action* action,
187 bool maySetupPatching = true);
188
189 void processCurrentPos(ModelStackWithThreeMainThings* modelStack, int32_t ticksSinceLast, bool reversed,
190 bool didPingpong = false, bool mayInterpolate = true);
191 void expectEvent(ModelStackWithThreeMainThings const* modelStack);
192
193 void shiftHorizontally(ModelStackWithThreeMainThings* modelStack, int32_t amount, int32_t effectiveLength);
194 void nudgeAutomationHorizontallyAtPos(int32_t pos, int32_t offset, int32_t lengthBeforeLoop, Action* action,
195 ModelStackWithThreeMainThings* modelStack, bool nudgeAutomation,
196 bool nudgeMPE, int32_t moveMPEDataWithinRegionLength = 0);
197 void deleteAllAutomation(Action* action, ModelStackWithThreeMainThings* modelStack);
198 void notifyPingpongOccurred(ModelStackWithThreeMainThings* modelStack);
199 void ensureSomeParamCollections(); // For debugging only
200 bool mightContainAutomation();
201
202#if ALPHA_OR_BETA_VERSION
203 ParamManagerForTimeline* toForTimeline() override;
204#endif
205
206 int32_t ticksTilNextEvent;
207 int32_t ticksSkipped;
208};
Definition action.h:75
Definition param_set.h:129
Definition instrument_clip.h:48
Definition midi_param_collection.h:30
Definition model_stack.h:269
Definition model_stack.h:251
Definition model_stack.h:231
Definition output.h:81
Definition param_collection_summary.h:24
Definition param_collection.h:39
Definition param_manager.h:174
Definition param_set.h:36
Definition patch_cable_set.h:41
Definition param_set.h:114
Definition song.h:104
Definition sound.h:71
Definition timeline_counter.h:28
Definition param_set.h:98