Deluge Firmware 1.3.0
Build date: 2025.04.16
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 shouldParamIndicateMiddleValue(ModelStackWithParamId const* modelStack) override;
103 bool doesParamIdAllowAutomation(ModelStackWithParamId const* modelStack) override;
104 int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam* modelStack) override;
105 int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam* modelStack) override;
106 deluge::modulation::params::Kind getParamKind() override { return kind; }
107
108 deluge::modulation::params::Kind kind = deluge::modulation::params::Kind::NONE;
109
110private:
111 std::array<AutoParam, deluge::modulation::params::kMaxNumUnpatchedParams> params_;
112};
113
114class PatchedParamSet final : public ParamSet {
115public:
116 PatchedParamSet(ParamCollectionSummary* summary);
117 void beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength) override;
118 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t oldValue,
119 bool automationChanged, bool automatedBefore, bool automatedNow) override;
120 int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam* modelStack) override;
121 int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam* modelStack) override;
122 bool shouldParamIndicateMiddleValue(ModelStackWithParamId const* modelStack) override;
124
125private:
126 std::array<AutoParam, deluge::modulation::params::kNumParams> params_;
127};
128
129class ExpressionParamSet final : public ParamSet {
130public:
131 ExpressionParamSet(ParamCollectionSummary* summary, bool forDrum = false);
132 void beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength) override;
133 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t oldValue,
134 bool automationChanged, bool automatedBefore, bool automatedNow) override;
135 bool mayParamInterpolate(int32_t paramId) override { return false; }
136 int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam* modelStack) override;
137 int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam* modelStack) override;
138 bool writeToFile(Serializer& writer, bool mustWriteOpeningTagEndFirst = false);
139 void readFromFile(Deserializer& reader, ParamCollectionSummary* summary, int32_t readAutomationUpToPos);
140 void moveRegionHorizontally(ModelStackWithParamCollection* modelStack, int32_t pos, int32_t length, int32_t offset,
141 int32_t lengthBeforeLoop, Action* action);
142 void clearValues(ModelStackWithParamCollection const* modelStack);
143 void cancelAllOverriding();
144 void deleteAllAutomation(Action* action, ModelStackWithParamCollection* modelStack) override;
146
147 // bendRanges being stored here in ExpressionParamSet still seems like the best option. I was thinking storing them
148 // in the ParamManager would make more sense, except for one thing
149 // - persistence when preset/Instrument changes. ExpressionParamSets do this unique thing where they normally aren't
150 // "stolen" or "backed up" - unless the last Clip is being deleted, in which case they do move to the
151 // backedUpParamManager. This is exactly the persistence we want for bendRanges too.
152 uint8_t bendRanges[2];
153
154private:
155 std::array<AutoParam, kNumExpressionDimensions> params_;
156};
Definition action.h:75
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:604
int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam *modelStack) override
Definition param_set.cpp:618
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 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
Definition storage_manager.h:119
Definition sound.h:71
Definition timeline_counter.h:28
Definition param.cpp:27
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