11namespace tracktion {
inline namespace engine
42 ClipEffect::EffectType,
int index);
44 virtual void initialise() {}
51 EffectType getType()
const;
53 struct ClipEffectRenderJob;
77 bool isUsingFile (
const AudioFile&)
const;
79 virtual void flushStateToValueTree() {}
89 virtual HashCode getIndividualHash()
const;
90 void valueTreeChanged()
override;
96 void invalidateDestination();
117 void flushStateToValueTree()
119 for (
auto ce : objects)
120 ce->flushStateToValueTree();
125 for (
auto ce : objects)
135 if (cachedHash == hashNeedsRecaching)
136 if (
auto ce = objects.
getLast())
137 cachedHash = ce->getHash();
147 return getCachedClipProperties().effectsRange.getStart();
155 return getCachedClipProperties().effectsRange.getLength();
163 return getCachedClipProperties().effectsRange;
172 return getCachedClipProperties().speedRatio;
177 for (
auto ce : objects)
178 if (ce->isUsingFile (af))
184 void notifyListenersOfRenderCompletion()
186 listeners.call (&Listener::renderComplete);
189 RenderManager::Job::Ptr createRenderJob (
const AudioFile& destFile,
const AudioFile& sourceFile)
const;
193 return v.hasType (IDs::EFFECT);
198 auto ce = ClipEffect::create (v, *
this);
200 listeners.call (&Listener::effectAdded, ce);
204 void deleteObject (ClipEffect* ce)
override
206 listeners.call (&Listener::effectRemoved, ce);
211 void newObjectAdded (ClipEffect*)
override
213 invalidateAllEffects();
216 void objectRemoved (ClipEffect*)
override
218 invalidateAllEffects();
221 void objectOrderChanged()
override
223 invalidateAllEffects();
225 listeners.call (&Listener::effectsReordered);
231 virtual void effectChanged() {}
234 virtual void effectsReordered() {}
235 virtual void renderComplete() {}
238 void addListener (
Listener* l) { listeners.add (l); }
239 void removeListener (Listener* l) { listeners.remove (l); }
255 enum { hashNeedsRecaching = -1 };
257 struct CachedClipProperties
262 speedRatio = c.getSpeedRatio();
264 if (c.getAutoTempo())
267 auto info =
AudioFile (c.edit.engine, c.getOriginalFile()).getInfo();
268 auto sourceTempo = c.getLoopInfo().getBpm (info);
269 speedRatio = c.edit.tempoSequence.getTempoAt (c.getPosition().time.getStart()).getBpm() / sourceTempo;
273 effectsRange = { c.getLoopStart(), c.getLoopStart() + c.getLoopLength() };
275 effectsRange = { TimePosition(), c.getSourceLength() / speedRatio };
279 double speedRatio = 1.0;
282 struct ClipPropertyWatcher;
283 friend class ClipEffect;
288 mutable HashCode cachedHash = hashNeedsRecaching;
290 int renderInhibitors = 0;
292 const CachedClipProperties& getCachedClipProperties()
const
294 if (cachedClipProperties ==
nullptr)
297 return *cachedClipProperties;
300 void invalidateAllEffects()
302 cachedHash = hashNeedsRecaching;
304 for (
auto ce : objects)
305 ce->invalidateDestination();
310 clip.cancelCurrentRender();
314 void timerCallback()
override
316 if (renderInhibitors > 0)
319 invalidateAllEffects();
320 listeners.
call (&Listener::effectChanged);
349 void initialise()
override
351 if (plugin !=
nullptr)
352 for (
auto ap : plugin->getAutomatableParameters())
358 HashCode getIndividualHash()
const override;
361 void valueTreeChanged()
override;
362 void timerCallback()
override;
386 HashCode getIndividualHash()
const override;
400 int getMaxNumNotes();
415 bool getNote (
int index)
const noexcept;
416 void setNote (
int index,
bool value);
422 int getNumNotes()
const;
424 void shiftChannel (
bool toTheRight);
425 void toggleAtInterval (
int interval);
426 void randomiseChannel();
441 HashCode getIndividualHash()
const override;
454 void initialise()
override;
460 HashCode getIndividualHash()
const override;
463 void valueTreeChanged()
override;
464 void timerCallback()
override;
481 HashCode getIndividualHash()
const override;
487 void editFinishedLoading();
503 void initialise()
override
505 if (plugin !=
nullptr)
506 for (
auto ap : plugin->getAutomatableParameters())
510 void flushStateToValueTree()
override;
513 HashCode getIndividualHash()
const override;
516 void valueTreeChanged()
override;
518 void timerCallback()
override;
ElementType getLast() const noexcept
void call(Callback &&callback)
void stopTimer() noexcept
void startTimer(int intervalInMilliseconds) noexcept
Base class for Clips that produce some kind of audio e.g.
HashCode getHash() const
Returns the hash for this effect.
virtual juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &sourceFile, double sourceLength)=0
Subclasses should return a job that can render the source.
virtual void sourceChanged()
Callback to indicate the destination file has changed.
virtual bool hasProperties()
Return true here to show a properties button in the editor and enable the propertiesButtonPressed cal...
TimeDuration getEffectsLength() const
Returns the length of the effect.
TimePosition getEffectsStartTime() const
Returns the start position in the file that the effect should apply to.
TimeRange getEffectsRange() const
Returns the range of the file that the effect should apply to.
double getSpeedRatioEstimate() const
Returns the speed ratio of the clip or an estimate of this if the clip is auto tempo.
HashCode getHash() const
Returns the hash for this set of effects.
The Tracktion Edit class!
Base class for things that can be selected, and whose properties can appear in the properties panel.
Manages a list of items that are currently selected.
#define JUCE_LEAK_DETECTOR(OwnerClass)
#define JUCE_DECLARE_WEAK_REFERENCEABLE(Class)
RangeType< TimePosition > TimeRange
A RangeType based on real time (i.e.
Represents a duration in real-life time.
Represents a position in real-life time.
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &sourceFile, double sourceLength) override
Subclasses should return a job that can render the source.
juce::ReferenceCountedObjectPtr< ClipEffect::ClipEffectRenderJob > createRenderJob(const AudioFile &, double sourceLength) override
Subclasses should return a job that can render the source.
bool hasProperties() override
Return true here to show a properties button in the editor and enable the propertiesButtonPressed cal...
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &, double sourceLength) override
Subclasses should return a job that can render the source.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &sourceFile, double sourceLength) override
Subclasses should return a job that can render the source.
bool hasProperties() override
Return true here to show a properties button in the editor and enable the propertiesButtonPressed cal...
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
bool hasProperties() override
Return true here to show a properties button in the editor and enable the propertiesButtonPressed cal...
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &sourceFile, double sourceLength) override
Subclasses should return a job that can render the source.
void curveHasChanged(AutomatableParameter &) override
Called when the automation curve has changed, point time, value or curve.
bool hasProperties() override
Return true here to show a properties button in the editor and enable the propertiesButtonPressed cal...
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &, double sourceLength) override
Subclasses should return a job that can render the source.
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &, double sourceLength) override
Subclasses should return a job that can render the source.
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &sourceFile, double sourceLength) override
Subclasses should return a job that can render the source.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
bool hasProperties() override
Return true here to show a properties button in the editor and enable the propertiesButtonPressed cal...
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &sourceFile, double sourceLength) override
Subclasses should return a job that can render the source.
bool hasProperties() override
Return true here to show a properties button in the editor and enable the propertiesButtonPressed cal...
void sourceChanged() override
Callback to indicate the destination file has changed.
juce::ReferenceCountedObjectPtr< ClipEffectRenderJob > createRenderJob(const AudioFile &, double sourceLength) override
Subclasses should return a job that can render the source.