Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
patch_cable_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#include "definitions_cxx.hpp"
20#include "modulation/params/param_collection.h"
21#include "modulation/patch/patch_cable.h"
22
23class Song;
26class LearnedMIDI;
27class MIDICable;
28
29struct CableGroup {
30 uint8_t first;
31 uint8_t end;
32};
33
35 ParamDescriptor destinationParamDescriptor;
36 uint32_t sources;
37 uint8_t firstCable;
38 uint8_t endCable;
39};
40
41class PatchCableSet final : public ParamCollection {
42public:
43 PatchCableSet(ParamCollectionSummary* summary);
44 ~PatchCableSet() override;
45
46 void setupPatching(ModelStackWithParamCollection const* modelStack);
47 bool doesDestinationDescriptorHaveAnyCables(ParamDescriptor destinationParamDescriptor);
48 uint8_t getPatchCableIndex(PatchSource from, ParamDescriptor destinationParamDescriptor,
49 ModelStackWithParamCollection const* modelStack = nullptr,
50 bool createIfNotFound = false);
51 void deletePatchCable(ModelStackWithParamCollection const* modelStack, uint8_t c);
52 bool patchCableIsUsable(uint8_t c, ModelStackWithThreeMainThings const* modelStack);
53 int32_t getModifiedPatchCableAmount(int32_t c, int32_t p);
54 void removeAllPatchingToParam(ModelStackWithParamCollection* modelStack, uint8_t p);
55 bool isSourcePatchedToSomething(PatchSource s);
56 bool isSourcePatchedToSomethingManuallyCheckCables(PatchSource s);
57 bool doesParamHaveSomethingPatchedToIt(int32_t p);
58
59 void tickSamples(int32_t numSamples, ModelStackWithParamCollection* modelStack) override;
60 void tickTicks(int32_t numSamples, ModelStackWithParamCollection* modelStack) override {};
61 void setPlayPos(uint32_t pos, ModelStackWithParamCollection* modelStack, bool reversed) override;
62 void playbackHasEnded(ModelStackWithParamCollection* modelStack) override;
63 void grabValuesFromPos(uint32_t pos, ModelStackWithParamCollection* modelStack) override;
64 void generateRepeats(ModelStackWithParamCollection* modelStack, uint32_t oldLength, uint32_t newLength,
65 bool shouldPingpong) override;
66 void appendParamCollection(ModelStackWithParamCollection* modelStack,
67 ModelStackWithParamCollection* otherModelStack, int32_t oldLength,
68 int32_t reverseThisRepeatWithLength, bool pingpongingGenerally) override;
69 void trimToLength(uint32_t newLength, ModelStackWithParamCollection* modelStack, Action* action,
70 bool maySetupPatching) override;
71 void shiftHorizontally(ModelStackWithParamCollection* modelStack, int32_t amount, int32_t effectiveLength) override;
72 void processCurrentPos(ModelStackWithParamCollection* modelStack, int32_t ticksSkipped, bool reversed,
73 bool didPingpong, bool mayInterpolate) override;
74 void beenCloned(bool copyAutomation, int32_t reverseDirectionWithLength) override;
75 ParamManagerForTimeline* getParamManager();
76
77 void writePatchCablesToFile(Serializer& writer, bool writeAutomation);
78 void readPatchCablesFromFile(Deserializer& reader, int32_t readAutomationUpToPos);
79 void deleteAllAutomation(Action* action, ModelStackWithParamCollection* modelStack) override;
80 void nudgeNonInterpolatingNodesAtPos(int32_t pos, int32_t offset, int32_t lengthBeforeLoop, Action* action,
81 ModelStackWithParamCollection* modelStack) override;
82
83 void remotelySwapParamState(AutoParamState* state, ModelStackWithParamId* modelStack) override;
84 AutoParam* getParam(ModelStackWithParamCollection const* modelStack, PatchSource s,
85 ParamDescriptor destinationParamDescriptor, bool allowCreation = false);
86 ModelStackWithAutoParam* getAutoParamFromId(ModelStackWithParamId* modelStack, bool allowCreation = false) override;
87 static int32_t getParamId(ParamDescriptor destinationParamDescriptor, PatchSource s);
88
89 AutoParam* getParam(int32_t paramId);
90
91 void notifyParamModifiedInSomeWay(ModelStackWithAutoParam const* modelStack, int32_t oldValue,
92 bool automationChanged, bool automatedBefore, bool automatedNow) override;
93 void notifyPingpongOccurred(ModelStackWithParamCollection* modelStack) override;
94
95 int32_t paramValueToKnobPos(int32_t paramValue, ModelStackWithAutoParam* modelStack) override;
96 int32_t knobPosToParamValue(int32_t knobPos, ModelStackWithAutoParam* modelStack) override;
97 bool isSourcePatchedToDestinationDescriptorVolumeInspecific(PatchSource s,
98 ParamDescriptor destinationParamDescriptor);
99 bool isAnySourcePatchedToParamVolumeInspecific(ParamDescriptor destinationParamDescriptor);
100 void grabVelocityToLevelFromMIDIInput(LearnedMIDI* midiInput);
101 void grabVelocityToLevelFromMIDICable(MIDICable& cable);
102 PatchCable* getPatchCableFromVelocityToLevel();
103
104 Destination* getDestinationForParam(int32_t p);
105
107
108 uint32_t sourcesPatchedToAnything[2]; // Only valid after setupPatching()
109
110 PatchCable patchCables[kMaxNumPatchCables]; // TODO: store these in dynamic memory.
111 uint8_t numUsablePatchCables;
112 uint8_t numPatchCables;
113
114 Destination* destinations[2];
115
116 bool shouldParamIndicateMiddleValue(ModelStackWithParamId const* modelStack) override { return true; };
117
118 static void dissectParamId(uint32_t paramId, ParamDescriptor* destinationParamDescriptor, PatchSource* s);
119
120private:
121 void swapCables(int32_t c1, int32_t c2);
122 void freeDestinationMemory(bool destructing);
123};
Definition action.h:75
Definition auto_param.h:36
Definition auto_param.h:44
Definition storage_manager.h:185
Definition learned_midi.h:30
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Definition model_stack.h:269
Definition model_stack.h:251
Definition model_stack.h:260
Definition model_stack.h:231
Definition param_collection_summary.h:24
Definition param_descriptor.h:27
Definition param_manager.h:174
void tickSamples(int32_t numSamples, ModelStackWithParamCollection *modelStack) override
tick interpolation by a number of ticks
Definition patch_cable_set.cpp:558
void tickTicks(int32_t numSamples, ModelStackWithParamCollection *modelStack) override
tick interpolation by a number of ticks
Definition patch_cable_set.h:60
Definition patch_cable.h:29
Definition storage_manager.h:119
Definition song.h:104
Kind
Definition param.h:42
@ PATCH_CABLE
Modulates the strength of the modulation between a mod source and another param.
Definition param.h:56
Definition patch_cable_set.h:29
Definition patch_cable_set.h:34