Deluge Firmware 1.3.0
Build date: 2026.07.29
Loading...
Searching...
No Matches
param_set.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/automation/auto_param.h"
22#include "modulation/params/param.h"
23#include "modulation/params/param_collection.h"
24#include "storage/storage_manager.h"
25#include <array>
26
27class Sound;
29class TimelineCounter;
31
32// ParamSet specifies a lot of stuff about how the params will be stored - there's always a fixed number, and they don't
33// need other info stored besides their index - like MIDI CC, or patch cable details. This differs from other inheriting
34// classes of ParamCollection.
35
36class ParamSet : public ParamCollection {
37protected:
39 int32_t numParams_;
40
41public:
43 ParamSet(int32_t newObjectSize, ParamCollectionSummary* summary);
44
45 inline int32_t getValue(int32_t p) { return params[p].getCurrentValue(); }
46 int32_t getValueAtPos(int32_t p, uint32_t pos, TimelineCounter* playPositionCounter);
47 void processCurrentPos(ModelStackWithParamCollection* modelStack, int32_t ticksSkipped, bool reversed,
48 bool didPingpong, bool mayInterpolate) final;
49 void writeParamAsAttribute(Serializer& writer, char const* name, int32_t p, bool writeAutomation,
50 bool onlyIfContainsSomething = false, int32_t* valuesForOverride = nullptr);
51 void readParam(Deserializer& reader, ParamCollectionSummary* summary, int32_t p, int32_t readAutomationUpToPos);
52 void tickSamples(int32_t numSamples, ModelStackWithParamCollection* modelStack) final;
53 void tickTicks(int32_t numTicks, ModelStackWithParamCollection* modelStack) final;
54 void setPlayPos(uint32_t pos, ModelStackWithParamCollection* modelStack, bool reversed) final;
55 void playbackHasEnded(ModelStackWithParamCollection* modelStack) final;
56 void grabValuesFromPos(uint32_t pos, ModelStackWithParamCollection* modelStack) final;
57 void generateRepeats(ModelStackWithParamCollection* modelStack, uint32_t oldLength, uint32_t newLength,
58 bool shouldPingpong) final;
59 void appendParamCollection(ModelStackWithParamCollection* modelStack,
60 ModelStackWithParamCollection* otherModelStack, int32_t oldLength,
61 int32_t reverseThisRepeatWithLength, bool pingpongingGenerally) final;
62 void beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength) override;
63 void cloneFrom(ParamCollection* otherParamSet, bool copyAutomation);
64 void copyOverridingFrom(ParamSet* otherParamSet);
65 void trimToLength(uint32_t newLength, ModelStackWithParamCollection* modelStack, Action* action,
66 bool maySetupPatching) final;
67 void nudgeNonInterpolatingNodesAtPos(int32_t pos, int32_t offset, int32_t lengthBeforeLoop, Action* action,
68 ModelStackWithParamCollection* modelStack) final;
69 void paramHasAutomationNow(ParamCollectionSummary* summary, int32_t p);
70 void paramHasNoAutomationNow(ModelStackWithParamCollection const* modelStack, int32_t p);
71
72 void shiftParamValues(int32_t p, int32_t offset);
73 void shiftParamVolumeByDB(int32_t p, float offset);
74 void shiftHorizontally(ModelStackWithParamCollection* modelStack, int32_t amount, int32_t effectiveLength) final;
75 void deleteAllAutomation(Action* action, ModelStackWithParamCollection* modelStack) override;
76 void deleteAutomationForParamBasicForSetup(ModelStackWithParamCollection* modelStack, int32_t p);
77 void insertTime(ModelStackWithParamCollection* modelStack, int32_t pos, int32_t lengthToInsert);
78 void deleteTime(ModelStackWithParamCollection* modelStack, int32_t startPos, int32_t lengthToDelete);
79 void backUpAllAutomatedParamsToAction(Action* action, ModelStackWithParamCollection* modelStack);
80 void notifyPingpongOccurred(ModelStackWithParamCollection* modelStack) final;
81
82 // For undoing / redoing
83 void remotelySwapParamState(AutoParamState* state, ModelStackWithParamId* modelStack) final;
84
85 int32_t getNumParams() { return numParams_; }
86
87 ModelStackWithAutoParam* getAutoParamFromId(ModelStackWithParamId* modelStack, bool allowCreation = true) final;
88 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t oldValue,
89 bool automationChanged, bool automatedBefore, bool automatedNow) override;
90
91 uint8_t topUintToRepParams;
92
93private:
94 void backUpParamToAction(int32_t p, Action* action, ModelStackWithParamCollection* modelStack);
95 void checkWhetherParamHasInterpolationNow(ModelStackWithParamCollection const* modelStack, int32_t p);
96};
97
98class UnpatchedParamSet final : public ParamSet {
99public:
100 UnpatchedParamSet(ParamCollectionSummary* summary);
101 void beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength) override;
102 bool shouldInterpolateWithFloat(ModelStackWithParamId const* modelStack) override;
103 bool shouldParamIndicateMiddleValue(ModelStackWithParamId const* modelStack) override;
104 bool doesParamIdAllowAutomation(ModelStackWithParamId const* modelStack) override;
105 bool shouldRecordUnautomatedParamChange(ModelStackWithParamId const* modelStack) override;
106 int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam* modelStack) override;
107 int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam* modelStack) override;
108 deluge::modulation::params::Kind getParamKind() override { return kind; }
109
110 deluge::modulation::params::Kind kind = deluge::modulation::params::Kind::NONE;
111
112private:
113 std::array<AutoParam, deluge::modulation::params::kMaxNumUnpatchedParams> params_;
114};
115
116class PatchedParamSet final : public ParamSet {
117public:
118 PatchedParamSet(ParamCollectionSummary* summary);
119 void beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength) override;
120 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t oldValue,
121 bool automationChanged, bool automatedBefore, bool automatedNow) override;
122 int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam* modelStack) override;
123 int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam* modelStack) override;
124 bool shouldParamIndicateMiddleValue(ModelStackWithParamId const* modelStack) override;
126
127private:
128 std::array<AutoParam, deluge::modulation::params::kNumParams> params_;
129};
130
131class ExpressionParamSet final : public ParamSet {
132public:
133 ExpressionParamSet(ParamCollectionSummary* summary, bool forDrum = false);
134 void beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength) override;
135 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t oldValue,
136 bool automationChanged, bool automatedBefore, bool automatedNow) override;
137 bool mayParamInterpolate(int32_t paramId) override { return false; }
138 int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam* modelStack) override;
139 int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam* modelStack) override;
140 bool writeToFile(Serializer& writer, bool mustWriteOpeningTagEndFirst = false);
141 void readFromFile(Deserializer& reader, ParamCollectionSummary* summary, int32_t readAutomationUpToPos);
142 void moveRegionHorizontally(ModelStackWithParamCollection* modelStack, int32_t pos, int32_t length, int32_t offset,
143 int32_t lengthBeforeLoop, Action* action);
144 void clearValues(ModelStackWithParamCollection const* modelStack);
145 void cancelAllOverriding();
146 void deleteAllAutomation(Action* action, ModelStackWithParamCollection* modelStack) override;
148
149 // bendRanges being stored here in ExpressionParamSet still seems like the best option. I was thinking storing them
150 // in the ParamManager would make more sense, except for one thing
151 // - persistence when preset/Instrument changes. ExpressionParamSets do this unique thing where they normally aren't
152 // "stolen" or "backed up" - unless the last Clip is being deleted, in which case they do move to the
153 // backedUpParamManager. This is exactly the persistence we want for bendRanges too.
154 uint8_t bendRanges[2];
155
156private:
157 std::array<AutoParam, kNumExpressionDimensions> params_;
158};
Definition action.h:79
Definition auto_param.h:36
Definition auto_param.h:44
Definition storage_manager.h:185
int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam *modelStack) override
Definition param_set.cpp:621
int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam *modelStack) override
Definition param_set.cpp:635
Definition model_stack.h:269
Definition model_stack.h:251
Definition model_stack.h:260
Definition param_collection_summary.h:24
Definition param_collection.h:39
Definition param_manager.h:174
Definition param_set.h:36
void deleteTime(ModelStackWithParamCollection *modelStack, int32_t startPos, int32_t lengthToDelete)
this is used in arranger view to delete time between automation nodes (shift + <>)
Definition param_set.cpp:322
void tickSamples(int32_t numSamples, ModelStackWithParamCollection *modelStack) final
tick interpolation by a number of ticks
Definition param_set.cpp:135
int32_t numParams_
Number of parameters in the params array.
Definition param_set.h:39
void tickTicks(int32_t numTicks, ModelStackWithParamCollection *modelStack) final
tick interpolation by a number of ticks
Definition param_set.cpp:150
void insertTime(ModelStackWithParamCollection *modelStack, int32_t pos, int32_t lengthToInsert)
this is used in arranger view to insert time between automation nodes (shift = <>)
Definition param_set.cpp:312
Definition storage_manager.h:119
Definition sound.h:71
Definition timeline_counter.h:28
Definition param.cpp:28
Kind
Definition param.h:42
@ PATCHED
Voice-local parameters which can be modulated via the mod matrix.
Definition param.h:46
@ EXPRESSION
Parameter connected to an MPE expression axis.
Definition param.h:58