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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_Track.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
18class Track : public EditItem,
19 public Selectable,
22 protected juce::AsyncUpdater
23{
24public:
26 Track (Edit&, const juce::ValueTree&, bool hasModifierList);
27
29 ~Track() override;
30
33
34 //==============================================================================
40 virtual void initialise();
41
45 virtual void flushStateToValueTree();
46
53
54 //==============================================================================
56 juce::String getName() const override { return trackName; }
57
59 void setName (const juce::String&);
60
65 void resetName();
66
68 virtual void sanityCheckName() {}
69
70 //==============================================================================
72 virtual bool isAudioTrack() const { return false; }
73
75 virtual bool isAutomationTrack() const { return false; }
76
78 virtual bool isFolderTrack() const { return false; }
79
81 virtual bool isMarkerTrack() const { return false; }
82
84 virtual bool isTempoTrack() const { return false; }
85
87 virtual bool isChordTrack() const { return false; }
88
90 virtual bool isArrangerTrack() const { return false; }
91
93 virtual bool isMasterTrack() const { return false; }
94
95 //==============================================================================
97 bool canContainMarkers() const { return isMarkerTrack(); }
98
100 bool canContainMIDI() const { return isAudioTrack(); }
101
103 bool canContainAudio() const { return isAudioTrack(); }
104
106 bool canContainEditClips() const { return isAudioTrack(); }
107
109 bool canContainPlugins() const { return isAudioTrack() || isFolderTrack() || isMasterTrack(); }
110
112 bool isMovable() const { return isAudioTrack() || isFolderTrack(); }
113
115 bool acceptsInput() const { return isAudioTrack(); }
116
118 bool createsOutput() const { return isAudioTrack(); }
119
121 bool wantsAutomation() const { return ! (isMarkerTrack() || isChordTrack() || isArrangerTrack()); }
122
126 virtual bool canContainPlugin (Plugin*) const = 0;
127
128 //==============================================================================
136
138 virtual bool isFrozen (FreezeType) const { return false; }
139
141 virtual void setFrozen (bool /*shouldBeFrozen*/, FreezeType){}
142
144 bool isHidden() const { return hidden; }
145
147 void setHidden (bool h) { hidden = h; }
148
150 bool isProcessing (bool includeParents) const;
151
153 void setProcessing (bool p) { processing = p; }
154
159 virtual bool processAudioNodesWhileMuted() const { return false; }
160
162 virtual juce::Array<Track*> getInputTracks() const { return {}; }
163
164 //==============================================================================
168 juce::Array<Track*> getAllSubTracks (bool recursive) const;
169
173 juce::Array<AudioTrack*> getAllAudioSubTracks (bool recursive) const;
174
178 TrackList* getSubTrackList() const { return trackList.get(); }
179
181 bool hasSubTracks() const { return trackList != nullptr; }
182
184 virtual Clip* findClipForID (EditItemID) const;
185
192 Track* getSiblingTrack (int delta, bool keepWithinSameParent) const;
193
194 //==============================================================================
196 virtual int getNumTrackItems() const { return 0; }
197
199 virtual TrackItem* getTrackItem (int /*index*/) const { return {}; }
200
202 virtual int indexOfTrackItem (TrackItem*) const { return -1; }
203
205 virtual int getIndexOfNextTrackItemAt (TimePosition) { return -1; }
206
208 virtual TrackItem* getNextTrackItemAt (TimePosition) { return {}; }
209
210 //==============================================================================
216
217 //==============================================================================
220
222 Track* getParentTrack() const { return cachedParentTrack; }
223
225 FolderTrack* getParentFolderTrack() const { return cachedParentFolderTrack; }
226
228 bool isAChildOf (const Track& possibleParent) const;
229
233 bool isPartOfSubmix() const;
234
238 int getIndexInEditTrackList() const;
239
241 int getTrackDepth() const;
242
243 //==============================================================================
248 virtual bool isMuted (bool /*includeMutingByDestination*/) const { return false; }
249
254 virtual bool isSolo (bool /*includeIndirectSolo*/) const { return false; }
255
260 virtual bool isSoloIsolate (bool /*includeIndirectSolo*/) const { return false; }
261
263 virtual void setMute (bool) {}
264
266 virtual void setSolo (bool) {}
267
269 virtual void setSoloIsolate (bool) {}
270
281
284
288 bool shouldBePlayed() const noexcept { return isAudible; }
289
294 void updateAudibility (bool areAnyTracksSolo);
295
296 //==============================================================================
299
302
305
308
310 void hideAutomatableParametersForSource (EditItemID pluginOrParameterID);
311
312 //==============================================================================
314 virtual bool containsPlugin (const Plugin*) const;
315
317 bool hasFreezePointPlugin() const;
318
323
327 virtual Plugin::Array getAllPlugins() const;
328
330 virtual void sendMirrorUpdateToAllPlugins (Plugin& changedPlugin) const;
331
334
335 //==============================================================================
337 ModifierList* getModifierList() const { return modifierList.get(); }
338
339 //==============================================================================
340 static const int minTrackHeightForDetail = 10;
341 static const int trackHeightForEditor = 180;
342 static const int frozenTrackHeight = 15;
344 //==============================================================================
346 void setColour (juce::Colour newColour) { colour = newColour; }
347
349 juce::Colour getColour() const { return colour; }
350
351 //==============================================================================
355 bool canShowImage() const;
356
360 void setTrackImage (const juce::String& idOrData);
361
365 juce::String getTrackImage() const { return imageIdOrData; }
366
370 bool imageHasChanged();
371
375 void setTags (const juce::StringArray&);
376
380 juce::String getTags() const { return tags.get(); }
381
385 const juce::StringArray& getTagsArray() const noexcept { return tagsArray; }
386
387 //==============================================================================
391protected:
393 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
395 void valueTreeChildAdded (juce::ValueTree&, juce::ValueTree&) override;
397 void valueTreeChildRemoved (juce::ValueTree&, juce::ValueTree&, int) override;
399 void valueTreeChildOrderChanged (juce::ValueTree&, int, int) override {}
401 void valueTreeParentChanged (juce::ValueTree&) override;
403 void handleAsyncUpdate() override;
404
408 virtual bool isTrackAudible (bool areAnyTracksSolo) const;
409
410private:
411 juce::WeakReference<Selectable> currentAutoParam;
414
416 juce::CachedValue<bool> hidden, processing;
417
418 juce::CachedValue<EditItemID> currentAutoParamPlugin;
419 juce::CachedValue<juce::String> currentAutoParamID;
420
422 juce::CachedValue<juce::String> imageIdOrData, tags;
423 juce::StringArray tagsArray;
424
425 bool imageChanged = false;
426 std::atomic<bool> isAudible { true };
427
428 SafeSelectable<Track> cachedParentTrack;
429 SafeSelectable<FolderTrack> cachedParentFolderTrack;
430
431 //==============================================================================
432 void updateTrackList();
433 void updateCachedParent();
434
436};
437
438}} // namespace tracktion { inline namespace engine
Type get() const noexcept
Base class for elements that have some kind of automatable parameters.
A clip in an edit.
Base class for objects that live inside an edit - e.g.
The Tracktion Edit class!
Holds a list of Modifiers that have been added to a Track.
Holds a sequence of plugins.
Holds a pointer to some type of Selectable, which automatically becomes null if the selectable is del...
Base class for things that can be selected, and whose properties can appear in the properties panel.
Base class for EditItems that live in a Track, e.g.
Base class for tracks which contain clips and plugins and can be added to Edit[s].
bool canContainAudio() const
Returns true if this Track can contain WaveAudioClip[s].
int getTrackDepth() const
Returns the number of parents within which this track is nested.
virtual bool isAutomationTrack() const
Returns true if this is an AutomationTrack.
virtual bool isMarkerTrack() const
Returns true if this is a MarkerTrack.
bool isMovable() const
Returns true if this Track is movable.
bool createsOutput() const
Returns true if this track creates audible output.
virtual void setFrozen(bool, FreezeType)
Attempts to freeze or unfreeze the track using a given FreezeType.
virtual Clip * findClipForID(EditItemID) const
Returns a clip one with a matching ID can be found on this Track.
juce::ValueTree getParentTrackTree() const
Returns the state of the parent Track.
void hideAutomatableParametersForSource(EditItemID pluginOrParameterID)
Hides a shown parameter if it matches the given ID.
PluginList pluginList
The Track's PluginList.
virtual bool isFrozen(FreezeType) const
Returns true if this track is frozen using the given type.
bool isProcessing(bool includeParents) const
Returns true if this track should be included in playback.
juce::Array< Track * > getAllSubTracks(bool recursive) const
Returns all nested tracks.
bool canContainMIDI() const
Returns true if this Track can contain MidiClip[s].
virtual int indexOfTrackItem(TrackItem *) const
Should return the index of the given TrackItem.
void setName(const juce::String &)
Sets the name of the Track.
virtual void sanityCheckName()
Sub-classes can impliment this to avoid certain characters being used in a name.
virtual juce::Array< Track * > getInputTracks() const
Should return any tracks which feed into this track.
AutomatableParameter * getCurrentlyShownAutoParam() const noexcept
Returns the parameter whos curve should be shown on this Track.
void setTrackImage(const juce::String &idOrData)
Sets some image data to use.
static const int trackHeightForEditor
The height at which inline editors should be shown.
virtual int getNumTrackItems() const
Should return the number of TrackItem[s] on this Track.
bool isAChildOf(const Track &possibleParent) const
Tests whether this is a child of a given Track.
bool acceptsInput() const
Returns true if this track can have inputs assigned to it.
bool wantsAutomation() const
Returns true if this track can show automation.
bool shouldBePlayed() const noexcept
Tests whether this track should be audible in the playback graph i.e.
bool hasSubTracks() const
Returns true if this track has any subtracks.
virtual bool isSolo(bool) const
Returns true if this track is soloed.
juce::String getTags() const
Returns the tags as a pipe-separated single String.
FreezeType
Determines the type of freeze.
@ individualFreeze
Freezes a track in to a single audio file.
@ groupFreeze
Freezes multiple tracks together in to a single file.
@ anyFreeze
Either a group or individual freeze.
Track * getSiblingTrack(int delta, bool keepWithinSameParent) const
Returns a sibling Track to this one.
bool canContainMarkers() const
Returns true if this Track can contain MarkerClip[s].
virtual bool containsPlugin(const Plugin *) const
Tests whether this Track or a clip on it contains the given plugin.
void setHidden(bool h)
Sets whether this track should be hidden from view.
bool canShowImage() const
Tests whether this Track can show an image.
virtual void flushStateToValueTree()
Flushes all plugin states on the track to the state object.
virtual bool isFolderTrack() const
Returns true if this is a FolderTrack.
void setTags(const juce::StringArray &)
Sets an array of Strings to use as tags.
virtual void setMute(bool)
Subclasses should implement this to mute themselves.
const juce::StringArray & getTagsArray() const noexcept
Returns the array of tags.
bool canContainEditClips() const
Returns true if this Track can contain EditClip[s].
virtual void setSolo(bool)
Subclasses should implement this to solo themselves.
virtual bool processAudioNodesWhileMuted() const
Subclasses can override this to ensure track contents are still played even when the track is muted.
int getIndexInEditTrackList() const
Returns the index of this track in a flat list of tracks contained in an Edit.
void setProcessing(bool p)
Sets whether this track should be included in playback.
bool canContainPlugins() const
Returns true if this Track can contain Plugin[s].
virtual TrackItem * getNextTrackItemAt(TimePosition)
Should return the TrackItem after this time.
juce::String getName() const override
Returns the name of the Track.
virtual bool isChordTrack() const
Returns true if this is a ChordTrack.
bool isPartOfSubmix() const
Tests whether this nested within a submix FolderTrack.
void setCurrentlyShownAutoParam(const AutomatableParameter::Ptr &)
Sets a parameter to display on this Track.
Track * getParentTrack() const
Returns the parent Track if this is a nested track.
virtual bool isTempoTrack() const
Returns true if this is a TempoTrack.
virtual bool canContainPlugin(Plugin *) const =0
Returns true if this track can contain a specific Plugin.
virtual bool isSoloIsolate(bool) const
Returns true if this track is solo isolated.
virtual void setSoloIsolate(bool)
Subclasses should implement this to solo isolate themselves.
virtual TrackItem * getTrackItem(int) const
Should return the TrackItem at the given index.
juce::ValueTree state
The state of this Track.
juce::Array< AutomatableEditItem * > getAllAutomatableEditItems() const
Returns all AutomatableEditItem[s] on this Track.
juce::Colour getColour() const
Returns the the of this.
juce::Array< AutomatableParameter * > getAllAutomatableParams() const
Returns all the parameters for this track's Plugin[s] and Modifier[s].
static const int minTrackHeightForDetail
The minimim height to show track contents at.
ModifierList * getModifierList() const
Returns the ModifierList for this track, if it has one.
virtual bool isMasterTrack() const
Returns true if this is a MasterTrack.
juce::Array< AudioTrack * > getAllAudioSubTracks(bool recursive) const
Returns all nested AudioTrack[s].
void setColour(juce::Colour newColour)
Sets a colour for this track to use.
TrackList * getSubTrackList() const
Returns the TrackList if this Track has any sub-tracks.
bool hasFreezePointPlugin() const
Tests whether this Track contains a FreezePointPlugin.
virtual int getIndexOfNextTrackItemAt(TimePosition)
Should return the index of the TrackItem after this time.
virtual Plugin::Array getAllPlugins() const
Returns all pugins on this Track.
juce::String getTrackImage() const
Returns previously set image data.
virtual bool isAudioTrack() const
Returns true if this is an AudioTrack.
~Track() override
Destructor.
virtual bool isMuted(bool) const
Returns true if this track is muted.
void flipAllPluginsEnablement()
Toggles the Plugin::isEnabled state for all Plugin[s] on this Track.
void visitAllAutomatableParams(const std::function< void(AutomatableParameter &)> &) const
Visits all the parameters for this track's Plugin[s] and Modifier[s].
void resetName()
Sets the name of the Track to an empty string.
virtual void initialise()
Initialises the Track.
virtual bool isArrangerTrack() const
Returns true if this is an ArrangerTrack.
static const int frozenTrackHeight
The height to show group frozen tracks.
MuteAndSoloLightState getMuteAndSoloLightState() const
Returns the mute a solo status.
FolderTrack * getParentFolderTrack() const
Returns the parent FolderTrack if this is nested in one.
MuteAndSoloLightState
Determines the status of the mute and solo indicators.
@ muteFlashing
Track is implicitly muted.
@ muteLit
Track is explicitly muted.
@ soloLit
Track is explicitly soloed.
@ soloIsolate
Track is explicitly solo isolated.
@ soloFlashing
Track is implicitly soloed.
bool isHidden() const
Returns true if this track should be hidden from view.
void refreshCurrentAutoParam()
Updates the current parameter bases on the set IDs.
virtual void insertSpaceIntoTrack(TimePosition, TimeDuration)
Should insert empty space in to the track, shuffling down any items after the time.
virtual bool isTrackAudible(bool areAnyTracksSolo) const
Returns whether this Track should be audible.
bool imageHasChanged()
Tests and resets a flag internally kept when the image changes.
virtual void sendMirrorUpdateToAllPlugins(Plugin &changedPlugin) const
Sends a message to all plugins that the given plugin has changed.
void updateAudibility(bool areAnyTracksSolo)
Updates the audibility state of the Track.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Represents a duration in real-life time.
Represents a position in real-life time.
ID for objects of type EditElement - e.g.
An iterable list of Track[s] that live either in an Edit or as subtracks of a Track.