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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_EditSnapshot.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//==============================================================================
19{
20public:
21 //==============================================================================
23
24 static Ptr getEditSnapshot (Engine&, ProjectItemID);
25
26 //==============================================================================
27 struct Marker
28 {
29 juce::String name;
30 juce::Colour colour;
31 TimeRange time;
32 };
33
34 //==============================================================================
36
38 ProjectItemID getID() const noexcept { return itemID; }
39
41 juce::File getFile() const { return sourceFile; }
42
44 juce::ValueTree getState() noexcept { return state; }
45
56 void setState (juce::ValueTree, TimeDuration editLength);
57
59 bool isValid() const;
60
63
66
69
70 //==============================================================================
71 // Set of cached properties of the last saved state
72 juce::String getName() const { return name; }
73 int getNumTracks() const { return numTracks; }
74 int getNumAudioTracks() const { return numAudioTracks; }
75 int getIndexOfTrackID (EditItemID trackID) const { return trackIDs.indexOf (trackID); }
76 juce::String getTrackName (int index) const { return trackNames[index]; }
77 juce::String getTrackNameFromID (EditItemID trackID) const { return trackNames[getIndexOfTrackID(trackID)]; }
78 bool isAudioTrack (int trackIndex) const { return audioTracks[trackIndex]; }
79 bool isTrackMuted (int trackIndex) const { return mutedTracks[trackIndex]; }
80 bool isTrackSoloed (int trackIndex) const { return soloedTracks[trackIndex]; }
81 bool isTrackSoloIsolated (int trackIndex) const { return soloIsolatedTracks[trackIndex]; }
82 int audioToGlobalTrackIndex (int audioIndex) const;
83
84 TimeDuration getLength() const { return TimeDuration::fromSeconds (length); }
85 TimePosition getMarkIn() const { return TimePosition::fromSeconds (markIn); }
86 TimePosition getMarkOut() const { return TimePosition::fromSeconds (markOut); }
87 bool areMarksActive() const { return marksActive; }
88
89 double getTempo() const { return tempo; }
90 int getTimeSigNumerator() const { return timeSigNumerator; }
91 int getTimeSigDenominator() const { return timeSigDenominator; }
92 int getPitch() const { return pitch; }
93
94 const juce::Array<Marker>& getMarkers() const { return markers; }
95 const juce::Array<EditItemID>& getTracks() const { return trackIDs; }
96 const juce::Array<ProjectItemID>& getEditClips() const { return editClipIDs; }
97 const juce::Array<ProjectItemID>& getClipsSourceIDs() const { return clipSourceIDs; }
98 HashCode getHash() const { return lastSaveTime.toMilliseconds(); }
99
100 //==============================================================================
101 struct Listener
102 {
103 virtual ~Listener() = default;
104 virtual void editChanged (EditSnapshot&) = 0;
105 };
106
107 void addListener (Listener* l) { listeners.add (l); }
108 void removeListener (Listener* l) { listeners.remove (l); }
109
110 Engine& engine;
111
112private:
113 //==============================================================================
114 struct ListHolder;
116
117 ProjectItemID itemID;
118 juce::File sourceFile;
119 juce::ValueTree state;
120 juce::Time lastSaveTime;
121
122 juce::String name;
123 int numTracks, numAudioTracks;
124 juce::StringArray trackNames;
125 juce::BigInteger audioTracks, mutedTracks, soloedTracks, soloIsolatedTracks;
126
128 juce::Array<ProjectItemID> editClipIDs, clipSourceIDs;
129 double length = 0.0, markIn = 0.0, markOut = 0.0, tempo = 0.0;
130 bool marksActive = false;
131 int timeSigNumerator = 4, timeSigDenominator = 4, pitch = 60;
132 juce::Array<Marker> markers;
133
135
136 //==============================================================================
138 void refreshFromProjectItem (ProjectItem::Ptr);
139 void refreshFromXml (const juce::XmlElement&, const juce::String&, double newLength);
140 void refreshFromState();
141 void clear();
142 void addEditClips (const juce::XmlElement& track);
143 void addClipSources (const juce::XmlElement& track);
144 void addMarkers (const juce::XmlElement& track);
145 void addSubTracksRecursively (const juce::XmlElement& parent, int& audioTrackNameNumber);
146
148};
149
150}} // namespace tracktion { inline namespace engine
int64 toMilliseconds() const noexcept
Holds a snapshot of an Edit file of the last time it was saved.
void setState(juce::ValueTree, TimeDuration editLength)
Sets the Edit XML that the XmlEdit should refer to.
void refreshCacheAndNotifyListeners()
Refreshes the cached properties and calls any listeners.
bool isValid() const
Returns true if the current source is a valid Edit.
juce::File getFile() const
Returns the File if this was created from one.
juce::ValueTree getState() noexcept
Returns the source Xml.
void refreshFromProjectManager()
Looks in the ProjectManager for the relevant ProjectItem and updates it's state to reflect this.
ProjectItemID getID() const noexcept
Returns the ProjectItemID.
juce::ReferenceCountedArray< EditSnapshot > getNestedEditObjects()
deals only with snapshots so it's relatively fast.
The Engine is the central class for all tracktion sessions.
An ID representing one of the items in a Project.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Represents a duration in real-life time.