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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_ClipOwner.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
19{
20public:
24 ClipOwner();
25
27 virtual ~ClipOwner();
28
31
34
37
39 virtual Edit& getClipOwnerEdit() = 0;
40
42 const juce::Array<Clip*>& getClips() const;
43
44protected:
46 void initialiseClipOwner (Edit&, juce::ValueTree clipParentState);
47
49 virtual void clipCreated (Clip&) = 0;
50
55 virtual void clipAddedOrRemoved() = 0;
56
60 virtual void clipOrderChanged() = 0;
61
63 virtual void clipPositionChanged() = 0;
64
65private:
66 struct ClipList;
68};
69
70//==============================================================================
73
76
77
78//==============================================================================
79//==============================================================================
82{
83 no, /*<< Don't remove existing clips. */
84 yes /*<< Replace existing clips with new ones. */
85};
86
88Clip* insertClipWithState (ClipOwner&, juce::ValueTree);
89
91Clip* insertClipWithState (ClipOwner&,
92 const juce::ValueTree& stateToUse, const juce::String& name, TrackItem::Type,
93 ClipPosition, DeleteExistingClips, bool allowSpottingAdjustment);
94
95//==============================================================================
97Clip* insertNewClip (ClipOwner&, TrackItem::Type, EditTimeRange);
98
100Clip* insertNewClip (ClipOwner&, TrackItem::Type, const juce::String& name, EditTimeRange);
101
103Clip* insertNewClip (ClipOwner&, TrackItem::Type, const juce::String& name, ClipPosition);
104
105//==============================================================================
108 ClipPosition, DeleteExistingClips);
109
111juce::ReferenceCountedObjectPtr<WaveAudioClip> insertWaveClip (ClipOwner&, const juce::String& name, ProjectItemID sourceID,
112 ClipPosition, DeleteExistingClips);
113
116
119
121juce::ReferenceCountedObjectPtr<EditClip> insertEditClip (ClipOwner&, TimeRange, ProjectItemID);
122
123//==============================================================================
125juce::Array<Clip*> deleteRegion (ClipOwner&, TimeRange);
126
128juce::Array<Clip*> deleteRegion (Clip&, TimeRange);
129
131juce::Array<Clip*> split (ClipOwner&, TimePosition);
132
134Clip* split (Clip&, TimePosition);
135
137[[ nodiscard ]] bool containsAnyMIDIClips (const ClipOwner&);
138
140template<typename ClipType>
141[[ nodiscard ]] juce::Array<ClipType*> getClipsOfType (const ClipOwner&);
142
144template<typename ClipType>
145[[ nodiscard ]] juce::Array<ClipType*> getClipsOfTypeRecursive (const ClipOwner&);
146
147
148//==============================================================================
149//==============================================================================
151bool isMasterTrack (const Track&);
152
154bool isTempoTrack (const Track&);
155
157bool isAutomationTrack (const Track&);
158
160bool isAudioTrack (const Track&);
161
163bool isFolderTrack (const Track&);
164
166bool isMarkerTrack (const Track&);
167
169bool isChordTrack (const Track&);
170
172bool isArrangerTrack (const Track&);
173
175bool isAudioTrack (const ClipOwner&);
176
178bool isFolderTrack (const ClipOwner&);
179
181bool isMarkerTrack (const ClipOwner&);
182
184bool isChordTrack (const ClipOwner&);
185
187bool isArrangerTrack (const ClipOwner&);
188
189//==============================================================================
191bool canContainMIDI (const ClipOwner&);
192
194bool canContainAudio (const ClipOwner&);
195
197bool isMovable (const Track&);
198
200bool isOnTop (const Track&);
201
202//==============================================================================
203// _ _ _ _
204// __| | ___ | |_ __ _ (_)| | ___
205// / _` | / _ \| __| / _` || || |/ __|
206// | (_| || __/| |_ | (_| || || |\__ \ _ _ _
207// \__,_| \___| \__| \__,_||_||_||___/(_)(_)(_)
208//
209// Code beyond this point is implementation detail...
210//
211//==============================================================================
212
213template<typename ClipType>
215{
217
218 for (auto clip : parent.getClips())
219 if (auto typedClip = dynamic_cast<ClipType*> (clip))
220 clips.add (typedClip);
221
222 return clips;
223}
224
225template<typename ClipType>
227{
229
230 results.addArray (getClipsOfType<ClipType> (parent));
231
232 for (auto clip : parent.getClips())
233 if (auto clipOwner = dynamic_cast<ClipOwner*> (clip))
234 results.addArray (getClipsOfTypeRecursive<ClipType> (*clipOwner));
235
236 return results;
237}
238
239}} // namespace tracktion { inline namespace engine
void addArray(const Type *elementsToAdd, int numElementsToAdd)
void add(const ElementType &newElement)
Base class for items that can contain clips.
ClipOwner()
Constructs an empty ClipOwner.
const juce::Array< Clip * > & getClips() const
Returns the clips this owner contains.
virtual void clipOrderChanged()=0
Called when clips have moved times so that their order has changed.
void initialiseClipOwner(Edit &, juce::ValueTree clipParentState)
Must be called once from the subclass constructor to init the clip owner.
virtual Selectable * getClipOwnerSelectable()=0
Must return the selectable if this ClipOwner is one.
virtual Edit & getClipOwnerEdit()=0
Must return the Edit this ClipOwner belongs to.
virtual void clipCreated(Clip &)=0
Called when a clip is created which could be during Edit load.
virtual void clipAddedOrRemoved()=0
Called when a clip is added or removed.
virtual void clipPositionChanged()=0
Called when a clip start or end position has changed.
virtual EditItemID getClipOwnerID()=0
Must return the ID of this ClipOwner.
virtual juce::ValueTree & getClipOwnerState()=0
Must return the state of this ClipOwner.
A clip in an edit.
The Tracktion Edit class!
Base class for things that can be selected, and whose properties can appear in the properties panel.
Type
Defines the types of item that can live on Track[s].
Base class for tracks which contain clips and plugins and can be added to Edit[s].
juce::Array< ClipType * > getClipsOfType(const ClipOwner &)
Returns the subclips of the given type.
bool containsAnyMIDIClips(const ClipOwner &co)
Returns true if the clip owner contains any MIDI clips.
bool canContainMIDI(const ClipOwner &co)
Returns true if this Track can contain MidiClip[s].
Clip * findClipForState(ClipOwner &co, const juce::ValueTree &v)
Returns a clip with the given state if the ClipOwner contains it.
bool canContainAudio(const ClipOwner &co)
Returns true if this Track can contain WaveAudioClip[s].
Clip * findClipForID(ClipOwner &co, EditItemID id)
Returns a clip with the given ID if the ClipOwner contains it.
bool isOnTop(const Track &track)
Returns true if this a global Track and should be on top of others.
bool isAutomationTrack(const Track &t)
Returns true if this is an AutomationTrack.
bool isFolderTrack(const Track &t)
Returns true if this is a FolderTrack.
juce::Array< Clip * > deleteRegion(ClipOwner &parent, TimeRange range)
Removes a region of a ClipOwner and returns any newly created clips.
bool isAudioTrack(const Track &t)
Returns true if this is an AudioTrack.
bool isMovable(const Track &)
Returns true if this Track is movable.
bool isArrangerTrack(const Track &t)
Returns true if this is an ArrangerTrack.
MidiClip::Ptr insertMIDIClip(ClipOwner &parent, const juce::String &name, TimeRange position)
Inserts a new MidiClip into the ClipOwner's clip list.
juce::ReferenceCountedObjectPtr< WaveAudioClip > insertWaveClip(ClipOwner &parent, const juce::String &name, const juce::File &sourceFile, ClipPosition position, DeleteExistingClips deleteExistingClips)
Inserts a new WaveAudioClip into the ClipOwner's clip list.
bool isMarkerTrack(const Track &t)
Returns true if this is a MarkerTrack.
EditClip::Ptr insertEditClip(ClipOwner &parent, TimeRange position, ProjectItemID sourceID)
Inserts a new EditClip into the ClipOwner's clip list.
juce::Array< ClipType * > getClipsOfTypeRecursive(const ClipOwner &)
Returns the subclips of the given type, if any clips contain other clips, this will also return those...
bool isChordTrack(const Track &t)
Returns true if this is a ChordTrack.
Clip * insertNewClip(ClipOwner &parent, TrackItem::Type type, const juce::String &name, EditTimeRange pos)
Inserts a new clip with the given type and name.
DeleteExistingClips
Determines behaviour for overwriting clips.
Clip * insertClipWithState(ClipOwner &clipOwner, juce::ValueTree clipState)
Inserts a clip with the given state in to the ClipOwner's clip list.
bool isMasterTrack(const Track &t)
Returns true if this is a MasterTrack.
juce::Array< Clip * > split(ClipOwner &parent, TimePosition time)
Splits the given clp owner at the time and returns any newly created clips.
bool isTempoTrack(const Track &t)
Returns true if this is a TempoTrack.
ID for objects of type EditElement - e.g.