11namespace tracktion {
inline namespace engine
28 currentAutoParamPlugin.referTo (
state, IDs::currentAutoParamPluginID, um,
EditItemID());
29 currentAutoParamID.
referTo (
state, IDs::currentAutoParamTag, um, {});
40 cachedParentTrack =
nullptr;
41 cachedParentFolderTrack =
nullptr;
42 masterReference.clear();
46 currentAutoParam = {};
52 p->flushPluginStateToValueTree();
63 imageIdOrData.
referTo (
state, IDs::imageIdOrData, um, {});
65 if (imageIdOrData.
get().isNotEmpty())
84 if (trackName != newName)
95 int index = 0, result = -1;
116 if (trackList !=
nullptr)
118 trackList->visitAllTracks ([&] (
Track& t)
134 if (trackList !=
nullptr)
135 trackList->visitAllTracks ([&] (
Track& t) { results.
add (&t);
return true; }, recursive);
143 if (
auto c = track->findClipForID (
id))
153 if (keepWithinSameParent)
156 tracks = ft->getAllSubTracks (
false);
165 if (
auto index = tracks.
indexOf (
const_cast<Track*
> (
this)); index >= 0)
166 return tracks[index + delta];
175 for (
auto p =
getParentTrack(); p !=
nullptr; p = p->getParentTrack())
199 for (
auto p =
getParentTrack(); p !=
nullptr; p = p->getParentTrack())
208 if (p->isSubmixFolder())
253 if (p->getPluginType() ==
"freezePoint")
265 if (modifierList !=
nullptr)
266 for (
auto m : modifierList->getModifiers())
270 for (
auto p : plugins)
271 if (
auto mpl = p->getMacroParameterList())
289 auto isVolPanVCA = [] (
Plugin* p)
292 ||
dynamic_cast<VCAPlugin*
> (p) !=
nullptr;
295 auto areAnyOn = [&isVolPanVCA] (
const PluginList& pl) ->
bool
298 if (! isVolPanVCA (p) && p->canBeDisabled() && p->isEnabled())
307 if (! isVolPanVCA (p) && p->canBeDisabled())
308 p->setEnabled (enable);
318 for (
int j = 0; j < p->getNumAutomatableParameters(); ++j)
319 params.
add (p->getAutomatableParameter (j).get());
321 params.
addArray (p->getMacroParameters());
324 if (modifierList !=
nullptr)
325 for (
auto m : modifierList->getModifiers())
326 params.
addArray (m->getAutomatableParameters());
335 if (
auto mpl = p->getMacroParameterList())
336 mpl->visitAllAutomatableParams (visit);
338 p->visitAllAutomatableParams (visit);
341 if (modifierList !=
nullptr)
342 for (
auto m : modifierList->getModifiers())
343 m->visitAllAutomatableParams (visit);
348 if (pluginID.
isValid() && paramID.isNotEmpty())
354 if (p.paramID == paramID && p.getOwnerID() == pluginID)
363 p->initialiseFully();
365 if (
auto ap = p->getAutomatableParameterByID (paramID))
369 for (
auto ap : p->getAutomatableParameters())
370 if (ap->paramName == paramID)
377 if (auto aei = dynamic_cast<AutomatableEditItem*> (m))
378 for (auto p : aei->getAutomatableParameters())
379 if (p->getOwnerID() == pluginID && p->paramID == paramID)
383 for (auto p : mpl->getMacroParameters())
384 if (p->getOwnerID() == pluginID && p->paramID == paramID)
393 currentAutoParamPlugin.forceUpdateOfCachedValue();
396 auto newParam = findAutomatableParam (edit, currentAutoParamPlugin.get(), currentAutoParamID.
get()).get();
398 if (currentAutoParam != newParam)
400 currentAutoParam = newParam;
412 currentAutoParamPlugin = param ==
nullptr ?
EditItemID() : param->getOwnerID();
413 currentAutoParamID = param ==
nullptr ?
juce::String() : param->paramID;
418 if (currentAutoParamPlugin == pluginOrParameterID
419 || currentAutoParamID == pluginOrParameterID.toString())
440 for (
auto p =
getParentTrack(); p !=
nullptr; p = p->getParentTrack())
452 for (
int j = p->getNumAutomatableParameters(); --j >= 0;)
454 if (
auto param = p->getAutomatableParameter (j))
456 auto& curve = param->getCurve();
457 auto valueAtInsertionTime = curve.getValueAt (
time);
459 for (
int k = curve.getNumPoints(); --k >= 0;)
460 if (curve.getPointTime (k) >=
time)
462 curve.getPointTime (k) + amountOfSpace,
463 curve.getPointValue (k),
false);
466 curve.addPoint (
time, valueAtInsertionTime, 0.0f);
469 curve.addPoint (
time + amountOfSpace, valueAtInsertionTime, 0.0f);
475void Track::updateTrackList()
481 if (trackList ==
nullptr)
492void Track::updateCachedParent()
496 cachedParentTrack =
dynamic_cast<Track*
> (edit.
trackCache.findItem (EditItemID::fromID (parent)));
498 cachedParentTrack =
nullptr;
500 auto newFolder =
dynamic_cast<FolderTrack*
> (cachedParentTrack.get());
502 if (cachedParentFolderTrack != newFolder)
504 if (cachedParentFolderTrack !=
nullptr)
505 cachedParentFolderTrack->setDirtyClips();
507 if (newFolder !=
nullptr)
508 newFolder->setDirtyClips();
510 cachedParentFolderTrack = newFolder;
524 imageIdOrData = idOrData;
548 else if (i == IDs::name)
553 juce::MessageManager::callAsync ([trackRef =
makeSafeRef (*
this)]
555 if (
auto t = trackRef.get())
556 SelectionManager::refreshAllPropertyPanelsShowing (*t);
561 else if (i == IDs::colour)
566 else if (i == IDs::imageIdOrData)
571 else if (i == IDs::currentAutoParamPluginID || i == IDs::currentAutoParamTag)
575 else if (i == IDs::expanded)
579 else if (i == IDs::process)
585 for (
auto t : tracks)
587 p->setProcessingEnabled (p->getOwnerTrack()->
isProcessing (true));
609 updateCachedParent();
612void Track::handleAsyncUpdate()
void addArray(const Type *elementsToAdd, int numElementsToAdd)
int indexOf(ParameterType elementToLookFor) const
void add(const ElementType &newElement)
bool addIfNotAlreadyThere(ParameterType newElement)
void triggerAsyncUpdate()
void forceUpdateOfCachedValue()
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
Type get() const noexcept
bool isValid() const noexcept
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
String replace(StringRef stringToReplace, StringRef stringToInsertInstead, bool ignoreCase=false) const
String substring(int startIndex, int endIndex) const
bool isValid() const noexcept
void addListener(Listener *listener)
ValueTree getParent() const noexcept
void removeListener(Listener *listener)
ValueTree getOrCreateChildWithName(const Identifier &type, UndoManager *undoManager)
Base class for elements that have some kind of automatable parameters.
Base class for objects that live inside an edit - e.g.
The Tracktion Edit class!
void visitAllAutomatableParams(bool includeTrackParams, const std::function< void(AutomatableParameter &)> &) const
Returns all automatable parameters in an Edit.
void deleteTrack(Track *)
Deletes a Track.
bool areAnyTracksSolo() const
Returns true if any tracks are soloed.
PluginCache & getPluginCache() noexcept
Returns the PluginCache which manages all active Plugin[s] for this Edit.
bool isLoading() const
Returns true if the Edit's not yet fully loaded.
void visitAllTracksRecursive(std::function< bool(Track &)>) const
Visits all tracks in the Edit with the given function.
EditItemCache< Track > trackCache
Quick way to find and iterate all Track[s] in the Edit.
juce::UndoManager & getUndoManager() noexcept
Returns the juce::UndoManager used for this Edit.
Holds a sequence of plugins.
virtual void changed()
This should be called to send a change notification to any SelectableListeners that are registered wi...
Base class for tracks which contain clips and plugins and can be added to Edit[s].
int getTrackDepth() const
Returns the number of parents within which this track is nested.
virtual bool isAutomationTrack() const
Returns true if this is an AutomationTrack.
virtual Clip * findClipForID(EditItemID) const
Returns a clip one with a matching ID can be found on this Track.
juce::ValueTree getParentTrackTree() const
Returns the state of the parent Track.
void hideAutomatableParametersForSource(EditItemID pluginOrParameterID)
Hides a shown parameter if it matches the given ID.
PluginList pluginList
The Track's PluginList.
bool isProcessing(bool includeParents) const
Returns true if this track should be included in playback.
juce::Array< Track * > getAllSubTracks(bool recursive) const
Returns all nested tracks.
void setName(const juce::String &)
Sets the name of the Track.
AutomatableParameter * getCurrentlyShownAutoParam() const noexcept
Returns the parameter whos curve should be shown on this Track.
void setTrackImage(const juce::String &idOrData)
Sets some image data to use.
bool isAChildOf(const Track &possibleParent) const
Tests whether this is a child of a given Track.
virtual bool isSolo(bool) const
Returns true if this track is soloed.
Track(Edit &, const juce::ValueTree &, bool hasModifierList)
Creates a track with a given state.
Track * getSiblingTrack(int delta, bool keepWithinSameParent) const
Returns a sibling Track to this one.
virtual bool containsPlugin(const Plugin *) const
Tests whether this Track or a clip on it contains the given plugin.
bool canShowImage() const
Tests whether this Track can show an image.
virtual void flushStateToValueTree()
Flushes all plugin states on the track to the state object.
virtual bool isFolderTrack() const
Returns true if this is a FolderTrack.
void setTags(const juce::StringArray &)
Sets an array of Strings to use as tags.
int getIndexInEditTrackList() const
Returns the index of this track in a flat list of tracks contained in an Edit.
bool canContainPlugins() const
Returns true if this Track can contain Plugin[s].
bool isPartOfSubmix() const
Tests whether this nested within a submix FolderTrack.
void setCurrentlyShownAutoParam(const AutomatableParameter::Ptr &)
Sets a parameter to display on this Track.
Track * getParentTrack() const
Returns the parent Track if this is a nested track.
virtual bool isSoloIsolate(bool) const
Returns true if this track is solo isolated.
juce::ValueTree state
The state of this Track.
juce::Array< AutomatableEditItem * > getAllAutomatableEditItems() const
Returns all AutomatableEditItem[s] on this Track.
juce::Array< AutomatableParameter * > getAllAutomatableParams() const
Returns all the parameters for this track's Plugin[s] and Modifier[s].
juce::Array< AudioTrack * > getAllAudioSubTracks(bool recursive) const
Returns all nested AudioTrack[s].
bool hasFreezePointPlugin() const
Tests whether this Track contains a FreezePointPlugin.
virtual Plugin::Array getAllPlugins() const
Returns all pugins on this Track.
virtual bool isAudioTrack() const
Returns true if this is an AudioTrack.
~Track() override
Destructor.
virtual bool isMuted(bool) const
Returns true if this track is muted.
void flipAllPluginsEnablement()
Toggles the Plugin::isEnabled state for all Plugin[s] on this Track.
void visitAllAutomatableParams(const std::function< void(AutomatableParameter &)> &) const
Visits all the parameters for this track's Plugin[s] and Modifier[s].
void resetName()
Sets the name of the Track to an empty string.
virtual void initialise()
Initialises the Track.
MuteAndSoloLightState getMuteAndSoloLightState() const
Returns the mute a solo status.
FolderTrack * getParentFolderTrack() const
Returns the parent FolderTrack if this is nested in one.
MuteAndSoloLightState
Determines the status of the mute and solo indicators.
@ muteFlashing
Track is implicitly muted.
@ muteLit
Track is explicitly muted.
@ soloLit
Track is explicitly soloed.
@ soloIsolate
Track is explicitly solo isolated.
@ soloFlashing
Track is implicitly soloed.
void refreshCurrentAutoParam()
Updates the current parameter bases on the set IDs.
virtual void insertSpaceIntoTrack(TimePosition, TimeDuration)
Should insert empty space in to the track, shuffling down any items after the time.
virtual bool isTrackAudible(bool areAnyTracksSolo) const
Returns whether this Track should be audible.
bool imageHasChanged()
Tests and resets a flag internally kept when the image changes.
virtual void sendMirrorUpdateToAllPlugins(Plugin &changedPlugin) const
Sends a message to all plugins that the given plugin has changed.
void updateAudibility(bool areAnyTracksSolo)
Updates the audibility state of the Track.
The VCA plugin sits on a folder track to control the overall level of all the volume/pan plugins in i...
The built-in Tracktion volume/pan plugin.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
juce::Array< Track * > getTopLevelTracks(const Edit &edit)
Returns all of the non-foldered tracks in an Edit.
juce::Array< MacroParameterList * > getAllMacroParameterLists(const Edit &edit)
Returns all the MacroParameterLists in an Edit.
juce::Array< Track * > getAllTracks(const Edit &edit)
Returns all the tracks in an Edit.
juce::ReferenceCountedArray< Modifier > getAllModifiers(const Edit &edit)
Returns all the Modifiers in an Edit.
SafeSelectable< SelectableType > makeSafeRef(SelectableType &selectable)
Creates a SafeSelectable for a given selectable object.
Represents a duration in real-life time.
Represents a position in real-life time.
ID for objects of type EditElement - e.g.
static bool isTrack(const juce::ValueTree &) noexcept
Returns true if the given ValeTree is for a known Track type.
static bool hasAnySubTracks(const juce::ValueTree &)
Returns true if the track has any sub tracks.
#define CRASH_TRACER
This macro adds the current location to a stack which gets logged if a crash happens.