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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_WaveAudioClip.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:
23
25 ~WaveAudioClip() override;
26
28
29 //==============================================================================
32
34 void addTake (const juce::File&);
35
39 void deleteAllUnusedTakes (bool deleteSourceFiles);
40
44 void deleteAllUnusedTakesConfirmingWithUser (bool deleteSourceFiles);
45
48
49 //==============================================================================
51 bool needsRender() const override;
53 RenderManager::Job::Ptr getRenderJob (const AudioFile& destFile) override;
57 void renderComplete() override;
58
60 bool isUsingFile (const AudioFile&) override;
61
62 //==============================================================================
64 void initialise() override;
66 void cloneFrom (Clip*) override;
67
68 //==============================================================================
71
73 bool isMidi() const override { return false; }
75 bool usesSourceFile() const override { return true; }
76
78 TimeDuration getSourceLength() const override;
80 void sourceMediaChanged() override;
81
83 juce::File getOriginalFile() const override;
85 HashCode getHash() const override;
86
88 void setLoopDefaults() override;
89
90 //==============================================================================
94 bool hasAnyTakes() const override { return getTakesTree().getNumChildren() > 0; }
96 int getNumTakes (bool includeComps) override;
98 juce::Array<ProjectItemID> getTakes() const override;
100 void clearTakes() override;
102 int getCurrentTake() const override;
104 void setCurrentTake (int takeIndex) override;
106 bool isCurrentTakeComp() override;
108 Clip::Array unpackTakes (bool toNewTracks) override;
109
111 void reassignReferencedItem (const ReferencedItem&, ProjectItemID newID, double newStartTime) override;
112
113private:
114 //==============================================================================
115 mutable TimeDuration sourceLength;
116 WaveCompManager::Ptr compManager;
117
118 static constexpr int takeIndexNeedsUpdating = -2;
119 mutable int currentTakeIndex = takeIndexNeedsUpdating;
120
121 juce::ValueTree getTakesTree() const { return state.getChildWithName (IDs::TAKES); }
122 void invalidateCurrentTake() noexcept;
123 void invalidateCurrentTake (const juce::ValueTree&) noexcept;
124
125 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
126 void valueTreeChildAdded (juce::ValueTree&, juce::ValueTree&) override;
127 void valueTreeChildRemoved (juce::ValueTree&, juce::ValueTree&, int) override;
128 void valueTreeChildOrderChanged (juce::ValueTree&, int, int) override;
129
130 //==============================================================================
131 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WaveAudioClip)
132};
133
134}} // namespace tracktion { inline namespace engine
int getNumChildren() const noexcept
ValueTree getChildWithName(const Identifier &type) const
Base class for Clips that produce some kind of audio e.g.
Base class for items that can contain clips.
A clip in an edit.
juce::ValueTree state
The ValueTree of the Clip state.
An ID representing one of the items in a Project.
An audio clip that uses an audio file as its source.
juce::File getOriginalFile() const override
Must return the file that the source ProjectItemID refers to.
int getCurrentTake() const override
Returns the current take index.
void renderComplete() override
Callback to indicate that the render has completed.
juce::Array< ProjectItemID > getTakes() const override
Returns the ProjectItemID of the clip's takes.
int getNumTakes(bool includeComps) override
Returns the total number of takes.
juce::String getRenderMessage() override
Override this to return a custom message to be displayed over waveforms during rendering.
bool hasAnyTakes() const override
Returns true if this clip has any takes.
void deleteAllUnusedTakesConfirmingWithUser(bool deleteSourceFiles)
Deletes all but the current takes but shows a confirmation dialog first.
bool usesSourceFile() const override
True if it references a source file - i.e.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
bool needsRender() const override
Subclasses should override this to return true if they need the rest of the render callbacks.
RenderManager::Job::Ptr getRenderJob(const AudioFile &destFile) override
Subclasses should override this to return a RenderJob suitable for rendering its source file.
HashCode getHash() const override
Must return a unique hash for this clip's source.
bool isCurrentTakeComp() override
Returns true if the current take is a comp.
TimeDuration getSourceLength() const override
Must return the length in seconds of the source material e.g.
void deleteAllUnusedTakes(bool deleteSourceFiles)
Deletes all but the current takes.
void sourceMediaChanged() override
Called when the source media file reference (attribute "source") has changed - i.e.
void setCurrentTake(int takeIndex) override
Sets a given take index to be the current take.
void cloneFrom(Clip *) override
Clones the given clip to this clip.
bool isUsingFile(const AudioFile &) override
Should return true if the clip is referencing the file in any way.
void setLoopDefaults() override
Override this to fill in the LoopInfo structure as best fits the source.
WaveCompManager & getCompManager()
Returns the WaveCompManager for this clip.
juce::StringArray getTakeDescriptions() const override
Returns the descriptions of any takes.
void clearTakes() override
Clears any takes this clip has.
void initialise() override
Initialises the Clip.
void addTake(ProjectItemID)
Adds a new take with the ProjectItemID as the source.
Clip::Array unpackTakes(bool toNewTracks) override
Attempts to unpack the takes to new clips.
bool isMidi() const override
Returns true if this is a MidiClip.
Represents a duration in real-life time.
ID for objects of type EditElement - e.g.