tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_RackType.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
15{
17
18 juce::ValueTree state;
19
20 juce::CachedValue<EditItemID> sourceID, destID;
21 juce::CachedValue<int> sourcePin, destPin;
22};
23
24
25//==============================================================================
26class RackType : public Selectable,
30{
31public:
32 RackType (const juce::ValueTree&, Edit&);
33 ~RackType() override;
34
36
37 juce::ValueTree createStateCopy (bool includeAutomation);
38 juce::Result restoreStateFromValueTree (const juce::ValueTree&);
39
40 //==============================================================================
41 static Ptr createTypeToWrapPlugins (const Plugin::Array&, Edit&);
42
43 //==============================================================================
44 // tells the rack type about each instance that will be using it..
45 // These are called by the initialise methods of the instances.
46 void registerInstance (RackInstance*, const PluginInitialisationInfo&);
47 void initialisePluginsIfNeeded (const PluginInitialisationInfo&) const;
48 void deregisterInstance (RackInstance*);
49
50 void updateAutomatableParamPositions (TimePosition);
51
52 double getLatencySeconds (double sampleRate, int blockSize);
53
54 //==============================================================================
55 juce::Array<Plugin*> getPlugins() const;
56
57 // check whether this plugin's allowed to go in a rack, so e.g. racks
58 // themselves aren't allowed.
59 static bool isPluginAllowed (const Plugin::Ptr&);
60
64 bool addPlugin (const Plugin::Ptr&, juce::Point<float> pos, bool canAutoConnect);
65
66 Plugin* getPluginForID (EditItemID);
67
68 juce::Point<float> getPluginPosition (const Plugin::Ptr&) const;
69 juce::Point<float> getPluginPosition (int index) const;
70 void setPluginPosition (int index, juce::Point<float> pos);
71
72 //==============================================================================
73 juce::Array<const RackConnection*> getConnections() const noexcept;
74
75 bool addConnection (EditItemID source, int sourcePin,
76 EditItemID dest, int destPin);
77
78 bool removeConnection (EditItemID source, int sourcePin,
79 EditItemID dest, int destPin);
80
81 // check that this doesn't create loops, etc
82 bool isConnectionLegal (EditItemID source, int sourcePin,
83 EditItemID dest, int destPin) const;
84
85 juce::Array<EditItemID> getPluginsWhichTakeInputFrom (EditItemID) const;
86
87 void checkConnections();
88 static void removeBrokenConnections (juce::ValueTree&, juce::UndoManager*);
89
90 void createInstanceForSideChain (Track&, const juce::BigInteger& channelMask,
91 EditItemID pluginID, int pinIndex);
92
93 //==============================================================================
94 juce::StringArray getInputNames() const;
95 juce::StringArray getOutputNames() const;
96
97 int addInput (int index, const juce::String& name);
98 int addOutput (int index, const juce::String& name);
99 void removeInput (int index);
100 void removeOutput (int index);
101
102 void renameInput (int index, const juce::String& name);
103 void renameOutput (int index, const juce::String& name);
104
105 bool pasteClipboard();
106
107 //==============================================================================
108 ModifierList& getModifierList() const noexcept;
109
110 //==============================================================================
111 juce::UndoManager* getUndoManager() const;
112
113 //==============================================================================
115
116 //==============================================================================
117 juce::StringArray getAudioInputNamesWithChannels() const;
118 juce::StringArray getAudioOutputNamesWithChannels() const;
119
120 static RackType::Ptr findRackTypeContaining (const Plugin&);
121
122 static const char* getRackPresetPrefix() noexcept { return "rackpreset::"; }
123
124 //==============================================================================
126 {
127 WindowState (RackType&, juce::ValueTree windowStateTree);
128
129 RackType& rack;
130 juce::ValueTree state;
132 };
133
134 juce::Array<WindowState*> getWindowStates() const;
135
136 void loadWindowPosition();
137 void saveWindowPosition();
138 void hideWindowForShutdown();
139
140 Edit& edit;
141
142 juce::ValueTree state; // do not change the order of
143 EditItemID rackID; // these two members!
144
146
147private:
148 struct PluginInfo
149 {
150 Plugin::Ptr plugin;
151 juce::ValueTree state;
152 };
153
154 struct RackPluginList;
156
157 struct ConnectionList;
158 std::unique_ptr<ConnectionList> connectionList;
159
160 struct WindowStateList;
161 std::unique_ptr<WindowStateList> windowStateList;
162
163 mutable std::unique_ptr<ModifierList> modifierList;
164
165 juce::Array<RackInstance*> activeRackInstances;
166 int numberOfInstancesInEdit = 0;
167
168 std::atomic<int> numActiveInstances { 0 };
169
170 //==============================================================================
171 bool arePluginsConnectedIndirectly (EditItemID src, EditItemID dest, int depth = 0) const;
172 void countInstancesInEdit();
173
174 void removeAllInputsAndOutputs();
175 void addDefaultInputs();
176 void addDefaultOutputs();
177
178 void triggerUpdate();
179 void updateRenderContext();
180
181 //==============================================================================
182 void valueTreeChildAdded (juce::ValueTree&, juce::ValueTree&) override;
183 void valueTreeChildRemoved (juce::ValueTree&, juce::ValueTree&, int) override;
184 void valueTreeChildOrderChanged (juce::ValueTree&, int, int) override;
185 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
186 void valueTreeParentChanged (juce::ValueTree&) override;
187 void valueTreeRedirected (juce::ValueTree&) override;
188};
189
190
191//==============================================================================
193{
194public:
197
198 void initialise (const juce::ValueTree&);
199
200 int size() const;
201 RackType::Ptr getRackType (int index) const;
202 RackType::Ptr getRackTypeForID (EditItemID) const;
203 RackType::Ptr findRackContaining (Plugin&) const;
204 RackType::Ptr addRackTypeFrom (const juce::ValueTree&);
205 RackType::Ptr addNewRack();
206 void removeRackType (const RackType::Ptr& type);
207 void importRackFiles (const juce::Array<juce::File>&);
208
209 const juce::Array<RackType*>& getTypes() const noexcept;
210
211private:
212 Edit& edit;
213 juce::ValueTree state;
214
215 struct ValueTreeList;
217
219};
220
221}} // namespace tracktion { inline namespace engine
The Tracktion Edit class!
Base class for elements which can contain macro parameters.
Holds a list of Modifiers that have been added to a Track.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
bool addPlugin(const Plugin::Ptr &, juce::Point< float > pos, bool canAutoConnect)
Adds a plugin to the Rack optionally connecting it to the input and outputs.
Base class for things that can be selected, and whose properties can appear in the properties panel.
Base class for tracks which contain clips and plugins and can be added to Edit[s].
#define JUCE_DECLARE_NON_COPYABLE(className)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Passed into Plugins when they are being initialised, to give them useful contextual information that ...
Represents a position in real-life time.
ID for objects of type EditElement - e.g.