Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
auto_param.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#include "definitions_cxx.hpp"
20#include "model/action/action.h"
21#include "modulation/params/param_node_vector.h"
22#include "storage/storage_manager.h"
23#include <cstdint>
24
25class InstrumentClip;
26class ParamNode;
27class Action;
28class ParamCollection;
29class Sound;
31class TimelineCounter;
32class Clip;
34
35// For backing up a snapshot
37public:
38 ParamNodeVector nodes;
39 int32_t value;
40};
41
42struct StolenParamNodes;
43
44class AutoParam {
45public:
46 AutoParam();
47 void init();
48
49 void setCurrentValueInResponseToUserInput(int32_t value, ModelStackWithAutoParam const* modelStack,
50 bool shouldLogAction = true, int32_t livePos = -1,
51 bool mayDeleteNodesInLinearRun = true, bool isMPE = false);
52 int32_t processCurrentPos(ModelStackWithAutoParam const* modelStack, bool reversed, bool didPinpong,
53 bool mayInterpolate = true, bool mustUpdateValueAtEveryNode = false);
54 void setValueForRegion(uint32_t pos, uint32_t length, int32_t value, ModelStackWithAutoParam const* modelStack,
55 ActionType actionType = ActionType::NOTE_EDIT);
56 void setValuePossiblyForRegion(int32_t value, ModelStackWithAutoParam const* modelStack, int32_t pos,
57 int32_t length, bool mayDeleteNodesInLinearRun = true);
58 int32_t getValueAtPos(uint32_t pos, ModelStackWithAutoParam const* modelStack, bool reversed = false);
60 bool tickSamples(int32_t numSamples);
62 bool tickTicks(int32_t numTicks);
63 void setPlayPos(uint32_t pos, ModelStackWithAutoParam const* modelStack, bool reversed);
64 bool grabValueFromPos(uint32_t pos, ModelStackWithAutoParam const* modelStack);
65 void generateRepeats(uint32_t oldLength, uint32_t newLength, bool shouldPingpong);
66 void cloneFrom(AutoParam* otherParam, bool copyAutomation);
67 Error beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength);
68 void copyOverridingFrom(AutoParam* otherParam);
69 void trimToLength(uint32_t newLength, Action* action, ModelStackWithAutoParam const* modelStack);
70 void deleteAutomation(Action* action, ModelStackWithAutoParam const* modelStack, bool shouldNotify = true);
71 void deleteAutomationBasicForSetup();
72 void writeToFile(Serializer& writer, bool writeAutomation, int32_t* valueForOverride = nullptr);
73 Error readFromFile(Deserializer& reader, int32_t readAutomationUpToPos);
74 bool containsSomething(uint32_t neutralValue = 0);
75 static bool containedSomethingBefore(bool wasAutomatedBefore, uint32_t valueBefore, uint32_t neutralValue = 0);
76 void shiftValues(int32_t offset);
77 void shiftParamVolumeByDB(float offset);
78 void shiftHorizontally(int32_t amount, int32_t effectiveLength);
79 void swapState(AutoParamState* state, ModelStackWithAutoParam const* modelStack);
80 void copy(int32_t startPos, int32_t endPos, CopiedParamAutomation* copiedParamAutomation, bool isPatchCable,
81 ModelStackWithAutoParam const* modelStack);
82 void paste(int32_t startPos, int32_t endPos, float scaleFactor, ModelStackWithAutoParam const* modelStack,
83 CopiedParamAutomation* copiedParamAutomation, bool isPatchCable);
84 Error makeInterpolationGoodAgain(int32_t clipLength, int32_t quantizationRShift);
85 void transposeCCValuesToChannelPressureValues();
86 void deleteTime(int32_t startPos, int32_t lengthToDelete, ModelStackWithAutoParam* modelStack);
87 void insertTime(int32_t pos, int32_t lengthToInsert);
88 void appendParam(AutoParam* otherParam, int32_t oldLength, int32_t reverseThisRepeatWithLength,
89 bool pingpongingGenerally);
90 void nudgeNonInterpolatingNodesAtPos(int32_t pos, int32_t offset, int32_t lengthBeforeLoop, Action* action,
91 ModelStackWithAutoParam const* modelStack);
92 void stealNodes(ModelStackWithAutoParam const* modelStack, int32_t pos, int32_t regionLength, int32_t loopLength,
93 Action* action, StolenParamNodes* stolenNodeRecord = nullptr);
94 void insertStolenNodes(ModelStackWithAutoParam const* modelStack, int32_t pos, int32_t regionLength,
95 int32_t loopLength, Action* action, StolenParamNodes* stolenNodeRecord);
96 void moveRegionHorizontally(ModelStackWithAutoParam const* modelStack, int32_t pos, int32_t length, int32_t offset,
97 int32_t lengthBeforeLoop, Action* action);
98 void deleteNodesWithinRegion(ModelStackWithAutoParam const* modelStack, int32_t pos, int32_t length);
108 int32_t setNodeAtPos(int32_t pos, int32_t value, bool shouldInterpolate);
109 int32_t homogenizeRegion(ModelStackWithAutoParam const* modelStack, int32_t startPos, int32_t length,
110 int32_t startValue, bool interpolateLeftNode, bool interpolateRightNode,
111 int32_t effectiveLength, bool reversed, int32_t posAtWhichClipWillCut = 2147483647);
112 int32_t getDistanceToNextNode(ModelStackWithAutoParam const* modelStack, int32_t pos, bool reversed);
113 void setCurrentValueWithNoReversionOrRecording(ModelStackWithAutoParam const* modelStack, int32_t value);
114
115 inline int32_t getCurrentValue() { return currentValue; }
116 int32_t getValuePossiblyAtPos(int32_t pos, ModelStackWithAutoParam* modelStack);
117 void notifyPingpongOccurred();
118
119 inline void setCurrentValueBasicForSetup(int32_t value) { currentValue = value; }
120
121 inline bool isAutomated() { return (nodes.getNumElements()); }
122
123 inline void cancelOverriding() { // Will also cancel "latching".
124 renewedOverridingAtTime = 0;
125 }
126
129
132 int32_t valueIncrementPerHalfTick;
133 uint32_t renewedOverridingAtTime; // If 0, it's off. If 1, it's latched until we hit some nodes / automation
134
135 // "Latching" happens when you start recording values, but then stops if you arrive at any pre-existing values. So
136 // it only works in empty stretches of time.
137
138private:
139 bool deleteRedundantNodeInLinearRun(int32_t lastNodeInRunI, int32_t effectiveLength,
140 bool mayLoopAroundBackToEnd = true);
141 void setupInterpolation(ParamNode* nextNode, int32_t effectiveLength, int32_t currentPos, bool reversed);
142 void homogenizeRegionTestSuccess(int32_t pos, int32_t regionEnd, int32_t startValue, bool interpolateStart,
143 bool interpolateEnd);
144 void deleteNodesBeyondPos(int32_t pos);
145};
Definition action.h:75
Definition auto_param.h:36
int32_t setNodeAtPos(int32_t pos, int32_t value, bool shouldInterpolate)
Make sure the value of this AutoParam will be value at time pos.
Definition auto_param.cpp:933
bool tickSamples(int32_t numSamples)
tick the interolator by a number of samples - used for internal synths
Definition auto_param.cpp:830
int32_t currentValue
Current value of the AutoParam. Updated by several functions.
Definition auto_param.h:131
ParamNodeVector nodes
The nodes that make up this parameter. If empty, currentValue should be used.
Definition auto_param.h:128
bool tickTicks(int32_t numTicks)
tick the interpolator by a number of ticks - used for midi
Definition auto_param.cpp:850
Definition clip.h:46
Definition copied_param_automation.h:28
Definition storage_manager.h:185
Definition instrument_clip.h:48
Definition model_stack.h:269
Definition param_collection.h:39
Definition param_node_vector.h:24
Definition param_node.h:23
Definition storage_manager.h:119
Definition sound.h:71
Definition timeline_counter.h:28
Definition param_node.h:45