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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_TrackItem.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
14//==============================================================================
19class TrackItem : public EditItem,
20 public Selectable,
22{
23public:
25 enum class Type
26 {
27 unknown,
28 wave,
29 midi,
30 edit,
31 step,
32 marker,
33 pitch,
34 timeSig,
36 video,
37 recording,
38 chord,
39 arranger,
41 };
42
47
49 ~TrackItem();
50
51 //==============================================================================
53 static const char* typeToString (Type);
54
57
60
63
68
69 //==============================================================================
71 virtual Track* getTrack() const = 0;
72
74 virtual bool isGrouped() const { return false; }
75
77 virtual TrackItem* getGroupParent() const { return {}; }
78
79 //==============================================================================
81 virtual ClipPosition getPosition() const = 0;
82
84 TimeRange getEditTimeRange() const { return getPosition().time; }
85
87 BeatRange getEditBeatRange() const;
88
91
96
99
102
105
108
111
112 //==============================================================================
114 EditItemID getTrackID() const;
115
116 const Type type;
118 //==============================================================================
120 template <typename ArrayType>
121 static void sortByTime (ArrayType& items)
122 {
123 std::sort (items.begin(), items.end(),
124 [] (const TrackItem* a, const TrackItem* b) { return a->getPosition().time.getStart() < b->getPosition().time.getStart(); });
125 }
126
130 template <typename ArrayType>
131 static void stableSortByTime (ArrayType& items)
132 {
133 std::stable_sort (items.begin(), items.end(),
134 [] (const TrackItem* a, const TrackItem* b) { return a->getPosition().time.getStart() < b->getPosition().time.getStart(); });
135 }
136
137private:
139};
140
141
142}} // namespace tracktion { inline namespace engine
Base class for objects that live inside an edit - e.g.
The Tracktion Edit class!
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.
Type
Defines the types of item that can live on Track[s].
@ timeSig
A time signature settings.
@ unknown
A placeholder for unknown items.
@ recording
A temporary recording clip.
const Type type
The type of this item.
BeatPosition getStartBeat() const
Returns the start beat in the Edit of this item.
static juce::Identifier clipTypeToXMLType(Type)
Returns an Identifier version of a TrackItem::Type.
static void stableSortByTime(ArrayType &items)
Helper function to sort an array of TrackItem[s] by their start time without changing the order of it...
static void sortByTime(ArrayType &items)
Helper function to sort an array of TrackItem[s] by their start time.
virtual Track * getTrack() const =0
Must return the track this item lives on.
BeatDuration getLengthInBeats() const
Returns the duration in beats the of this item.
static TrackItem::Type stringToType(const juce::String &)
Returns the TrackItem::Type of a type string.
virtual TrackItem * getGroupParent() const
If this clip is part of a group, this should return the parent item it belongs to.
TimePosition getTimeOfRelativeBeat(BeatDuration) const
Returns an Edit time point for a given number of beats from the start of this item.
virtual ClipPosition getPosition() const =0
Must return the position of this item.
static TrackItem::Type xmlTagToType(juce::StringRef)
Returns the TrackItem::Type of a type string.
EditItemID getTrackID() const
Returns the ID of the Track this item lives on.
virtual bool isGrouped() const
Should return true if this clip is part of a group.
BeatRange getEditBeatRange() const
Returns the beat range of this item.
BeatPosition getEndBeat() const
Returns the end beat in the Edit of this item.
BeatDuration getOffsetInBeats() const
Returns an the offset of this item in beats.
static juce::String getSuggestedNameForNewItem(Type)
Returns a text string for a new clip of the given type.
BeatPosition getContentStartBeat() const
Returns the start beat of the content in the Edit of this item.
TimeRange getEditTimeRange() const
Returns the time range of this item.
static const char * typeToString(Type)
Returns the string version of a TrackItem::Type.
BeatPosition getBeatOfRelativeTime(TimeDuration) const
Returns an Edit beat point for a given number of seconds from the start of this item.
Base class for tracks which contain clips and plugins and can be added to Edit[s].
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
T sort(T... args)
T stable_sort(T... args)
Represents a duration in beats.
Represents a position in beats.
Represents a duration in real-life time.
Represents a position in real-life time.
Represents the position of a clip on a timeline.
TimeRange time
The TimeRange this ClipPosition occupies.
ID for objects of type EditElement - e.g.