11namespace tracktion {
inline namespace engine
29 virtual void initialise();
32 virtual HashCode getBaseTakeHash (
int takeIndex)
const = 0;
33 virtual double getTakeLength (
int takeIndex)
const = 0;
34 virtual double getOffset()
const = 0;
35 virtual double getLoopLength()
const = 0;
36 virtual bool getAutoTempo() = 0;
37 virtual double getSourceTempo() = 0;
39 virtual float getRenderProgress()
const {
return 1.0f; }
40 virtual void discardCachedData() {}
46 virtual void flattenTake (
int takeIndex,
bool deleteSourceFiles) = 0;
52 Clip& getClip() const noexcept {
return clip; }
185 int lastRenderedTake = -1;
186 HashCode lastHash = 0;
187 double maxCompLength, effectiveTimeMultiplier;
188 double lastOffset = 1.0, lastTimeRatio = 1.0;
191 void keepSectionsSortedAndInRange();
197 bool displayWarning =
false;
201 void refreshCachedTakeLengths();
202 void updateOffsetAndRatioFromSource();
203 void addOrRemoveListenerIfNeeded();
208 void valueTreeChildOrderChanged (
juce::ValueTree&,
int,
int)
override {}
213 struct RenderTrigger;
228 CompManager::Ptr getCompManager (
Clip&);
260 HashCode getBaseTakeHash (
int takeIndex)
const override {
return getProjectItemIDForTake (takeIndex).
getItemID(); }
261 double getTakeLength (
int takeIndex)
const override;
262 double getOffset()
const override;
263 double getLoopLength()
const override;
264 bool getAutoTempo()
override;
265 double getSourceTempo()
override;
267 float getRenderProgress()
const override;
270 void flattenTake (
int takeIndex,
bool deleteSourceFiles)
override;
290 enum { compGeneratorDelay = 500 };
303 void setProjectItemIDForTake (
int takeIndex,
ProjectItemID)
const;
305 AudioFile getSourceFileForTake (
int takeIndex)
const;
306 juce::File getDefaultTakeFile (
int index)
const;
309 void timerCallback()
override;
324 void initialise()
override;
325 MidiList* getSequenceLooped (
int index);
328 HashCode getBaseTakeHash (
int takeIndex)
const override;
329 double getTakeLength (
int takeIndex)
const override;
330 double getOffset()
const override {
return 0.0; }
331 double getLoopLength()
const override {
return getTakeLength (0); }
332 bool getAutoTempo()
override {
return false; }
333 double getSourceTempo()
override {
return 1.0; }
335 float getRenderProgress()
const override {
return 1.0f; }
336 void discardCachedData()
override;
339 void flattenTake (
int takeIndex,
bool deleteSourceFiles)
override;
ValueTree getChild(int index) const
int getNumChildren() const noexcept
const var & getProperty(const Identifier &name) const noexcept
Smart wrapper for writing to an audio file.
virtual int getCurrentTake() const
Returns the current take index.
int getTotalNumTakes() const
Returns the total number of takes including comp takes.
~CompManager() override
Destructor.
int findSectionWithEndTime(juce::Range< double > range, int takeIndex, bool &timeFoundAtStartOfSection) const
Returns the index of the section whose end lies within the given time range.
void moveSectionToEndAt(juce::ValueTree §ion, double newEndTime)
Moves a section to an absolute end time also moving the previous section's end time by the same ammou...
virtual void triggerCompRender()=0
Triggers the render of the comp.
bool shouldDisplayWarning() const noexcept
Returns true if the source should display a warning about using multi-tempo changes.
juce::ValueTree getActiveTakeTree() const
Returns the active take tree.
void setActiveTakeIndex(int index)
Sets the active take index.
juce::String getTakeName(int index) const
Returns the name of a take.
double getSpeedRatio() const
Returns the effective speed ratio used for displaying waveforms.
HashCode getTakeHash(int takeIndex) const
Returns a hash code representing a take.
int getActiveTakeIndex() const
Returns the active take index.
juce::ValueTree splitSectionAtTime(double time)
Find the current section at the given time and splits it in two ready for a new comp section.
void changeSectionIndexAtTime(double time, int takeIndex)
Changes the index of the active comp's section at a given time.
void removeSectionsWithinRange(juce::Range< double > timeRange, const juce::ValueTree §ionToKeep)
Removes all sections which lie within the given time range.
virtual juce::ValueTree addNewComp()=0
Adds a new comp to the end of the takes list optionally making it active.
virtual void setStripToUpdate(juce::Component *)
Sets a component to be updated during render processes.
double getSourceTimeMultiplier() const
Returns the current time multiplier in use by the source, either the speed ratio or auto tempo ratio.
virtual juce::ValueTree pasteComp(const juce::ValueTree &)
Pastes an existing comp to this manager and returns the newly added tree.
juce::Range< double > getCompRange() const
Returns the time range available for comping i.e.
double getMaxCompLength() const
Returns the maximum length that a comp can be.
int getNumComps() const
Returns the number of comps that are comps.
virtual void flattenTake(int takeIndex, bool deleteSourceFiles)=0
Should flatten the comp and remove all other takes.
void removeSectionIndexAtTime(double time, int takeIndex)
Removes a section from the comp at the given time if the section is at the given take index.
bool isCurrentTakeComp() const
Returns true if the current take is a comp.
bool isTakeComp(const juce::ValueTree &takeTree) const
Returns true if the given take is a comp.
juce::ValueTree addSection(int takeIndex, double endTime)
Adds a new section at a given time and returns the index of it.
void moveSection(juce::ValueTree §ion, double timeDelta)
Moves a section by the specified time delta also moving the previous section's end time by the same a...
juce::Range< double > getSectionTimes(const juce::ValueTree &) const
Returns the time range a given section occupies for a given take.
juce::ValueTree getSection(int takeIndex, int sectionIndex) const
Returns the section at the given index of a given take.
void moveSectionEndTime(juce::ValueTree §ion, double newTime)
Moves a section's end time to the new time specified.
int getNumTakes() const
Returns the number of takes that are not comps.
juce::ValueTree findSectionAtTime(double time)
Returns either the section for the current comp at a given time or if a whole take is being used the ...
void removeSection(const juce::ValueTree §ionToRemove)
Removes a section from the active comp if it is within range.
bool isTakeComp(int takeIndex) const
Returns true if the given take at an index is a comp.
juce::ValueTree addNewComp() override
Adds a new comp to the end of the takes list optionally making it active.
void flattenTake(int takeIndex, bool deleteSourceFiles) override
Should flatten the comp and remove all other takes.
void triggerCompRender() override
Triggers the render of the comp.
An ID representing one of the items in a Project.
int getItemID() const
Returns the ID of the item within the project.
An audio clip that uses an audio file as its source.
juce::ValueTree pasteComp(const juce::ValueTree &compTree) override
Pastes an existing comp to this manager and returns the newly added tree.
CompRenderContext * createRenderContext() const
Returns a context to render the current taste of this comp.
void flattenTake(int takeIndex, bool deleteSourceFiles) override
Should flatten the comp and remove all other takes.
void triggerCompRender() override
Triggers the render of the comp.
void setStripToUpdate(juce::Component *strip) override
Sets a component to be updated during render processes.
juce::ValueTree addNewComp() override
Adds a new comp to the end of the takes list optionally making it active.
static bool renderTake(CompRenderContext &, AudioFileWriter &, juce::ThreadPoolJob &, std::atomic< float > &progress)
Renders the comp using the given writer and ThreadPoolJob.
void updateThumbnails(juce::Component &, juce::OwnedArray< SmartThumbnail > &thumbnails) const
Updates an array of thumbnails so they represent the takes and are in the correct order etc.
juce::File getCurrentCompFile() const
Returns the current comp file.
Updates a strip during a comp render and notifies the Clip when it finishes.
Re-calls flatten take to allow the comp time to finish rendering if needed.