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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_TrackItem.cpp
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 : EditItem (id, ed), type (t)
16{
17}
18
22
24{
25 switch (t)
26 {
27 case Type::wave: return "wave";
28 case Type::midi: return "midi";
29 case Type::edit: return "edit";
30 case Type::step: return "sequencer";
31 case Type::marker: return "marker";
32 case Type::pitch: return "pitch";
33 case Type::timeSig: return "timesig";
34 case Type::collection: return "collection";
35 case Type::video: return "video";
36 case Type::chord: return "chord";
37 case Type::arranger: return "arranger";
38 case Type::container: return "container";
39 case Type::recording:
40 case Type::unknown:
41 default: return "unknown";
42 }
43}
44
46{
47 if (s == "wave") return Type::wave;
48 if (s == "midi") return Type::midi;
49 if (s == "edit") return Type::edit;
50 if (s == "sequencer") return Type::step;
51 if (s == "marker") return Type::marker;
52 if (s == "barsBeatsMarker") return Type::marker;
53 if (s == "absoluteMarker") return Type::marker;
54 if (s == "pitch") return Type::pitch;
55 if (s == "timesig") return Type::timeSig;
56 if (s == "collection") return Type::collection;
57 if (s == "video") return Type::video;
58 if (s == "chord") return Type::chord;
59 if (s == "arranger") return Type::arranger;
60 if (s == "container") return Type::container;
61
62 return Type::unknown;
63}
64
66{
67 switch (t)
68 {
69 case Type::wave: return IDs::AUDIOCLIP;
70 case Type::midi: return IDs::MIDICLIP;
71 case Type::edit: return IDs::EDITCLIP;
72 case Type::step: return IDs::STEPCLIP;
73 case Type::marker: return IDs::MARKERCLIP;
74 case Type::chord: return IDs::CHORDCLIP;
75 case Type::arranger: return IDs::ARRANGERCLIP;
76 case Type::container: return IDs::CONTAINERCLIP;
77 case Type::pitch:
78 case Type::timeSig:
80 case Type::video:
81 case Type::recording:
82 case Type::unknown:
83 default: jassertfalse; return nullptr;
84 }
85}
86
88{
89 if (tag == IDs::AUDIOCLIP) return Type::wave;
90 if (tag == IDs::MIDICLIP) return Type::midi;
91 if (tag == IDs::EDITCLIP) return Type::edit;
92 if (tag == IDs::STEPCLIP) return Type::step;
93 if (tag == IDs::MARKERCLIP) return Type::marker;
94 if (tag == IDs::CHORDCLIP) return Type::chord;
95 if (tag == IDs::ARRANGERCLIP) return Type::arranger;
96 if (tag == IDs::CONTAINERCLIP) return Type::container;
97
99 return Type::unknown;
100}
101
103{
104 switch (t)
105 {
106 case Type::wave: return TRANS("New Audio Clip");
107 case Type::midi: return TRANS("New MIDI Clip");
108 case Type::edit: return TRANS("New Edit Clip");
109 case Type::step: return TRANS("New Step Clip");
110 case Type::marker: return TRANS("New Marker");
111 case Type::arranger: return TRANS("New Arranger");
112 case Type::container: return TRANS("New Container Clip");
113 case Type::chord: return {};
114 case Type::pitch:
115 case Type::timeSig:
116 case Type::collection:
117 case Type::video:
118 case Type::recording:
119 case Type::unknown:
120 default: jassertfalse; break;
121 }
122
123 return {};
124}
125
127{
128 if (auto track = getTrack())
129 return track->itemID;
130
132 return {};
133}
134
135BeatRange TrackItem::getEditBeatRange() const { return edit.tempoSequence.toBeats (getPosition().time); }
136BeatPosition TrackItem::getStartBeat() const { return edit.tempoSequence.toBeats (getPosition().getStart()); }
137BeatPosition TrackItem::getContentStartBeat() const { return edit.tempoSequence.toBeats (getPosition().getStartOfSource()); }
139BeatDuration TrackItem::getOffsetInBeats() const { return BeatDuration::fromBeats (getPosition().getOffset().inSeconds() * edit.tempoSequence.getBeatsPerSecondAt (getPosition().getStart())); }
140
141BeatPosition TrackItem::getEndBeat() const { return edit.tempoSequence.toBeats (getPosition().getEnd()); }
142TimePosition TrackItem::getTimeOfRelativeBeat (BeatDuration b) const { return edit.tempoSequence.toTime (getStartBeat() + b); }
143BeatPosition TrackItem::getBeatOfRelativeTime (TimeDuration t) const { return edit.tempoSequence.toBeats (getPosition().getStart() + t); }
144
145}} // namespace tracktion { inline namespace engine
Base class for objects that live inside an edit - e.g.
The Tracktion Edit class!
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.
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.
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.
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.
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.
TrackItem(Edit &, EditItemID, Type)
Creates a TrackItem with an ID and type.
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.
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.
#define TRANS(stringLiteral)
#define jassertfalse
Represents a duration in beats.
Represents a position in beats.
Represents a duration in real-life time.
Represents a position in real-life time.
ID for objects of type EditElement - e.g.
time