11namespace tracktion {
inline namespace engine
34 : levels (
std::move (l)) {}
37 float getGain() const noexcept {
return levels ? dbToGain (levels->dbGain.get()) : 1.0f; }
40 float getPan() const noexcept {
return levels ?
static_cast<float> (levels->pan.get()) : 0.0f; }
43 bool isMute() const noexcept {
return levels && levels->mute.get(); }
52 const float pv =
getPan() * g;
120 [[ nodiscard ]]
virtual bool isMidi()
const = 0;
212 virtual bool canLoop()
const {
return false; }
312 bool isGrouped()
const override {
return groupID.get().isValid(); }
457 bool isInitialised =
false;
458 bool cloneInProgress =
false;
495namespace ClipConstants
523 return tracktion::engine::details::followActionDurationTypeFromString (v);
528 return tracktion::engine::details::toString (v);
Type get() const noexcept
Base class for items that can contain clips.
Represents a slot on a track that a Clip can live in to be played as a launched clip.
virtual void disableLooping()
Disables all looping.
virtual juce::Array< TimePosition > getRescaledMarkPoints() const
Returns the mark points relative to the start of the clip, rescaled to the current speed.
virtual TimePosition getLoopStart() const
Returns the start time of the loop start point.
virtual Plugin::Array getAllPlugins()
Returns all the plugins on the clip.
juce::Array< ReferencedItem > getReferencedItems() override
Returns an array of any ReferencedItem[s] e.g.
EditItemID getGroupID() const noexcept
Returns the ID of the group.
virtual bool beatBasedLooping() const
Returns true if this clip's looping is based on beats or false if absolute time.
juce::CachedValue< BeatDuration > followActionBeats
Determines the time for which a launched clip will play before a follow action is taken.
ClipSlot * getClipSlot() const
Returns the parent ClipSlot this clip is on (if any).
virtual void sendMirrorUpdateToAllPlugins(Plugin &) const
Sends an update to all plugins mirroing the one passed in.
static bool isClipState(const juce::ValueTree &)
Checks whether a ValueTree is some kind of clip state.
ClipTrack * getClipTrack() const
Returns the parent ClipTrack this clip is on (if any).
TimePosition getTimeOfContentBeat(BeatPosition) const
Returns time of a beat number.
virtual juce::String getName() const override
Returns the name of the clip.
virtual bool canBeAddedTo(ClipOwner &)=0
Tests whether this clip can go on the given parent.
void changed() override
This should be called to send a change notification to any SelectableListeners that are registered wi...
CollectionClip * getGroupClip() const
Returns this as a CollectionClip if it is one.
void setOffset(TimeDuration newOffset)
Sets the offset of the clip, i.e.
TimePosition getSpottingPoint() const
Returns the first marked time in the source file which can be used for syncronising newly added clips...
virtual bool hasAnyTakes() const
Returns true if this clip has any takes.
virtual void setUsesGlobalLaunchQuatisation(bool)
Some clip types can be launched, if that's possible, this sets whether the clip's quantisation or the...
void trimAwayOverlap(TimeRange editRangeToTrim)
Trims away any part of the clip that overlaps this region.
virtual bool isLooping() const
Returns true if this clip is currently looping.
virtual void pitchTempoTrackChanged()
Called when there are pitch or tempo changes made which might require clips to adjust timing informat...
juce::ValueTree state
The ValueTree of the Clip state.
virtual void flushStateToValueTree()
Can be overridden to ensure any state (e.g.
virtual TimeDuration getMaximumLength()
Returns the maximum length this clip can have.
virtual void removePlugin(const Plugin::Ptr &)
Removes the given plugin from the clip if the clip supports plugins.
virtual void rescale(TimePosition pivotTimeInEdit, double factor)
stretches and scales this clip relative to a fixed point in the edit.
void setStart(TimePosition newStart, bool preserveSync, bool keepLength)
Sets the start time of the clip.
Track * getTrack() const override
Returns the parent Track this clip is on (if any).
juce::String getLinkGroupID() const
Returns the link ID of this clip.
virtual bool isMidi() const =0
Returns true if this is a MidiClip.
void reassignReferencedItem(const ReferencedItem &, ProjectItemID, double) override
Should be implemented to change the underlying source to a new ProjectItemID.
virtual int getNumTakes(bool)
Returns the total number of takes.
virtual void initialise()
Initialises the Clip.
virtual PluginList * getPluginList()
Returns the PluginList for this clip if it has one.
BeatPosition getContentBeatAtTime(TimePosition) const
Returns the beat number (with offset) at the given time.
ClipOwner * getParent() const
Returns the parent ClipOwner this clip is on.
virtual void setLoopRange(TimeRange)
Sets the loop range the clip should use in seconds.
void setColour(juce::Colour col)
Sets the colour property of this clip.
virtual std::shared_ptr< LaunchHandle > getLaunchHandle()
Some clip types can be launched, if that's possible, this returns a handle to trigger starting/stoppi...
virtual bool canLoop() const
Returns true if this clip is capable of looping.
virtual PatternGenerator * getPatternGenerator()
Returns the PatternGenerator for this clip if it has one.
virtual bool usesSourceFile() const
True if it references a source file - i.e.
virtual void sourceMediaChanged()
Called when the source media file reference (attribute "source") has changed - i.e.
virtual void cloneFrom(Clip *)
Clones the given clip to this clip.
void removeFromParent()
Removes this clip from the parent track or container clip.
void setLength(TimeDuration newLength, bool preserveSync)
Sets the length of the clip.
virtual juce::Colour getColour() const
Returns the colour property of this clip.
bool moveTo(ClipOwner &)
Moves the clip to a new parent (if possible).
SyncType getSyncType() const
Returns the sync type clip is using.
bool isGrouped() const override
Returns true if the clip is part of a group.
~Clip() override
Destructor.
virtual void setShowingTakes(bool shouldShow)
Sets whether the clip should be showing takes.
void updateLinkedClips()
Triggers a call to cloneFrom for all clips with the same linkID.
virtual BeatPosition getLoopStartBeats() const
Returns the beat position of the loop start point.
double getSpeedRatio() const noexcept
Returns the speed ratio i.e.
virtual void setNumberOfLoops(int)
Sets the clip looping a number of times.
virtual TimeDuration getLoopLength() const
Returns the length of loop in seconds.
juce::CachedValue< bool > disabled
Whether the Clip is disabled or not.
virtual void setCurrentTake(int)
Sets a given take index to be the current take.
void addListener(Listener *)
Adds a Listener.
juce::CachedValue< FollowActionDurationType > followActionDurationType
The type of duration to use for when to trigger the follow action.
void setName(const juce::String &newName)
Sets a new name for a clip.
virtual Clip::Array unpackTakes(bool)
Attempts to unpack the takes to new clips.
juce::CachedValue< double > followActionNumLoops
Determines the number of loops for which a launched clip will play before a follow action is taken.
virtual juce::Array< TimePosition > getInterestingTimes()
Returns times for snapping to, relative to the Edit.
virtual void setLoopRangeBeats(BeatRange)
Sets the loop range the clip should use in beats.
virtual bool usesGlobalLaunchQuatisation()
Some clip types can be launched, if that's possible, this returns whether the clip's quantisation or ...
virtual bool isMuted() const =0
Returns true if the clip is muted.
virtual void setSpeedRatio(double)
Sets a speed ratio i.e.
TimeRange getLoopRange() const
Returns the loop range in seconds.
BeatRange getLoopRangeBeats() const
Returns the loop range in beats.
virtual bool isShowingTakes() const
Returns true if the clip is showing takes.
juce::File getCurrentSourceFile() const
Returns the current source file, this is different to the SourceFileReference as it could be a tempor...
juce::CachedValue< juce::Colour > colour
The colour property.
virtual FollowActions * getFollowActions()
Some clip types can be launched, if that's possible, this can be used to determine the action to perf...
virtual juce::Colour getDefaultColour() const =0
Returns the default colour for this clip.
virtual LaunchQuantisation * getLaunchQuantisation()
Some clip types can be launched, if that's possible, this returns a quantisation that can be used for...
virtual juce::StringArray getTakeDescriptions() const
Returns the descriptions of any takes.
void setLinkGroupID(juce::String newLinkID)
Sets the link ID to link this clip with others.
juce::ListenerList< Listener > & getListeners()
Returns the listener list so Nodes can manually call them.
juce::UndoManager * getUndoManager() const
Returns the UndoManager.
bool isLinked() const
Returns true if this clip is linked with any others.
ClipPosition getPosition() const override
Returns the ClipPosition on the parent Track.
virtual bool addClipPlugin(const Plugin::Ptr &, SelectionManager &)
Adds a plugin to the clip.
void setEnd(TimePosition newEnd, bool preserveSync)
Sets the end of the clip.
FollowActionDurationType
Defines the types of duration follow actions can use.
@ beats
A number of beats.
@ loops
A number of loops.
static Ptr createClipForState(const juce::ValueTree &, ClipOwner &targetParent)
Creates a clip for a given ValueTree representation.
virtual int getCurrentTake() const
Returns the current take index.
void setGroup(EditItemID newGroupID)
Sets the clip to be part of a group.
virtual void setMuted(bool)
Mutes or unmutes the clip.
void setCurrentSourceFile(const juce::File &)
Sets a new source file for this clip.
SourceFileReference & getSourceFileReference()
Returns the SourceFileReference of the Clip.
SyncType
Determines the clip sync type.
@ syncBarsBeats
Sync to beats.
@ syncAbsolute
Sync to abslute time.
virtual BeatDuration getLoopLengthBeats() const
Returns the length of loop in beats.
void removeListener(Listener *)
Removes a Listener.
void setPosition(ClipPosition newPosition)
Sets the position of the clip.
virtual void setSyncType(SyncType sync)
Sets the sync type for the clip.
virtual void clearTakes()
Clears any takes this clip has.
virtual bool isCurrentTakeComp()
Returns true if the current take is a comp.
TrackItem * getGroupParent() const override
Returns the parent TrackItem if part of a group.
An interface for objects within an edit that can be exported.
Represents a launch quantisation.
Holds a sequence of plugins.
An ID representing one of the items in a Project.
Manages a list of items that are currently selected.
This class wraps a string that is generally held in a 'source' property, and which is a reference to ...
Base class for EditItems that live in a Track, e.g.
Type
Defines the types of item that can live on Track[s].
Base class for tracks which contain clips and plugins and can be added to Edit[s].
const double speedRatioMax
Maximum speed ratio.
const double speedRatioMin
Minimum speed ratio.
Holds a clip's level state.
Represents a duration in beats.
Represents a position in beats.
Represents a duration in real-life time.
Represents a position in real-life time.
Asyncronously call a function.
Represents the position of a clip on a timeline.
Listener interface to be notified of recorded MIDI being sent to the plugins.
virtual void midiMessageGenerated(Clip &, const juce::MidiMessage &)=0
Called when a recorded MidiMessage has been generated and sent.
ID for objects of type EditElement - e.g.
Provides a thread-safe way to share a clip's levels with an audio engine without worrying about the C...
float getGain() const noexcept
Returns the clip's absolute gain.
float getPan() const noexcept
Returns the clip's pan from -1.0 to 1.0.
float getGainIncludingMute() const noexcept
Returns the clip's gain if the clip is not muted.
bool isMute() const noexcept
Returns true if the clip is muted.
void getLeftAndRightGains(float &left, float &right) const noexcept
Reutrns the left and right gains taking in to account mute and pan values.
LiveClipLevel() noexcept=default
Creates an empty LiveClipLevel.