Deluge Firmware 1.3.0
Build date: 2026.10.29
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 void destructAndForgetMainParamCollections(); // Retains expression params, like forgetParamCollections()
66 bool ensureExpressionParamSetExists(bool forDrum = false);
67
68 inline int32_t getExpressionParamSetOffset() { return expressionParamSetOffset; }
69
70 ExpressionParamSet* getOrCreateExpressionParamSet(bool forDrum = false); // Will return NULL if can't create
71
72 inline ParamCollectionSummary* getExpressionParamSetSummary() { // Will return one containing NULL if didn't exist
73 return &summaries[getExpressionParamSetOffset()];
74 }
75
76 inline ExpressionParamSet* getExpressionParamSet() { // Will return NULL if didn't exist
77 return (ExpressionParamSet*)getExpressionParamSetSummary()->paramCollection;
78 }
79
80 inline MIDIParamCollection* getMIDIParamCollection() {
81 if (!summaries[0].paramCollection) {
82 FREEZE_WITH_ERROR("E409");
83 }
84 return (MIDIParamCollection*)summaries[0].paramCollection;
85 }
86
87 inline ParamCollectionSummary* getMIDIParamCollectionSummary() {
88 if (!summaries[0].paramCollection) {
89 FREEZE_WITH_ERROR("E409");
90 }
91 return &summaries[0];
92 }
93
94 inline UnpatchedParamSet* getUnpatchedParamSet() {
95 if (!summaries[0].paramCollection) {
96 FREEZE_WITH_ERROR("E410");
97 }
98 return (UnpatchedParamSet*)summaries[0].paramCollection;
99 }
100
101 inline ParamCollectionSummary* getUnpatchedParamSetSummary() {
102 if (!summaries[0].paramCollection) {
103 FREEZE_WITH_ERROR("E410");
104 }
105 return &summaries[0];
106 }
107
108 inline PatchedParamSet* getPatchedParamSet() {
109 if (!summaries[1].paramCollection) {
110 FREEZE_WITH_ERROR("E411");
111 }
112 return (PatchedParamSet*)summaries[1].paramCollection;
113 }
114
115 inline ParamCollectionSummary* getPatchedParamSetSummary() {
116 if (!summaries[1].paramCollection) {
117 FREEZE_WITH_ERROR("E411");
118 }
119 return &summaries[1];
120 }
121
122 inline ParamCollectionSummary* getPatchCableSetSummary() {
123 if (!summaries[2].paramCollection) {
124 FREEZE_WITH_ERROR("E412");
125 }
126 return &summaries[2];
127 }
128
129 inline PatchCableSet* getPatchCableSet() {
130 if (!summaries[2].paramCollection) {
131 FREEZE_WITH_ERROR("E412");
132 }
133 return (PatchCableSet*)summaries[2].paramCollection;
134 }
135
136 ModelStackWithParamCollection* getPatchCableSet(ModelStackWithThreeMainThings const* modelStack);
137
138 inline PatchCableSet* getPatchCableSetAllowJibberish() { // Don't ask.
139 return (PatchCableSet*)summaries[2].paramCollection;
140 }
141
142 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t currentValueChanged,
143 bool automationChanged, bool paramAutomatedNow);
144
145 virtual ParamManagerForTimeline* toForTimeline();
146
147 bool resonanceBackwardsCompatibilityProcessed;
148 uint8_t expressionParamSetOffset;
149
150 // This list should be terminated by an object whose values are all zero. Yes, all of them must be zero, because if
151 // we know this, we can check for stuff faster.
152 ParamCollectionSummary summaries[PARAM_COLLECTIONS_STORAGE_NUM];
153};
154
155class ParamManagerForTimeline final : public ParamManager { // I want to rename this one to "with automation"
156public:
157 ParamManagerForTimeline();
158
159 void tickSamples(int32_t numSamples, ModelStackWithThreeMainThings* modelStack);
160 void setPlayPos(uint32_t pos, ModelStackWithThreeMainThings* modelStack, bool reversed);
161 void expectNoFurtherTicks(ModelStackWithThreeMainThings* modelStack);
162 void grabValuesFromPos(uint32_t pos, ModelStackWithThreeMainThings* modelStack);
163 void generateRepeats(ModelStackWithThreeMainThings* modelStack, uint32_t oldLength, uint32_t newLength,
164 bool shouldPingpong);
165 void appendParamManager(ModelStackWithThreeMainThings* modelStack, ModelStackWithThreeMainThings* otherModelStack,
166 int32_t oldLength, int32_t reverseThisRepeatWithLength, bool pingpongingGenerally);
167 void trimToLength(uint32_t newLength, ModelStackWithThreeMainThings* modelStack, Action* action,
168 bool maySetupPatching = true);
169
170 void processCurrentPos(ModelStackWithThreeMainThings* modelStack, int32_t ticksSinceLast, bool reversed,
171 bool didPingpong = false, bool mayInterpolate = true);
172 void expectEvent(ModelStackWithThreeMainThings const* modelStack);
173
174 void shiftHorizontally(ModelStackWithThreeMainThings* modelStack, int32_t amount, int32_t effectiveLength);
175 void nudgeAutomationHorizontallyAtPos(int32_t pos, int32_t offset, int32_t lengthBeforeLoop, Action* action,
176 ModelStackWithThreeMainThings* modelStack, bool nudgeAutomation,
177 bool nudgeMPE, int32_t moveMPEDataWithinRegionLength = 0);
178 void deleteAllAutomation(Action* action, ModelStackWithThreeMainThings* modelStack);
179 void notifyPingpongOccurred(ModelStackWithThreeMainThings* modelStack);
180 void ensureSomeParamCollections(); // Freezes if empty - the DEFINITELY_SOME loops require at least one
181 bool mightContainAutomation();
182
183 ParamManagerForTimeline* toForTimeline() override;
184
185 int32_t ticksTilNextEvent;
186 int32_t ticksSkipped;
187};
Definition action.h:79
Definition param_set.h:131
Definition instrument_clip.h:48
Definition midi_param_collection.h:30
Definition model_stack.h:264
Definition model_stack.h:246
Definition model_stack.h:227
Definition output.h:81
Definition param_collection_summary.h:24
Definition param_collection.h:39
Definition param_manager.h:155
Definition param_set.h:36
Definition patch_cable_set.h:41
Definition param_set.h:116
Definition song.h:103
Definition sound.h:76
Definition timeline_counter.h:28
Definition param_set.h:98