11namespace tracktion {
inline namespace engine
206 bool tryToMatchTempo,
bool tryToMatchPitch,
bool* couldMatchTempo,
209 bool forceMidiToDrums =
false,
214 bool tryToMatchTempo,
bool* couldMatchTempo,
217 bool forceMidiToDrums =
false,
291 const bool reallocateOnDestruction;
732 juce::String artist, title, album, date, genre, comment, trackNumber;
757 template<
typename OwnerType>
765 void timerCallback()
override
770 owner.editFinishedLoading();
833 const int instanceId;
847 struct MirroredPluginUpdateTimer;
854 struct UndoTransactionTimer;
856 struct PluginChangeTimer;
858 struct FrozenTrackCallback;
869 bool shouldRestartPlayback =
false;
870 bool blinkBright =
false;
871 bool lowLatencyMonitoring =
false;
872 bool hasChanged =
false;
873 bool ignoreLeftViewLimit;
874 LoadContext* loadContext =
nullptr;
876 int numUndoTransactionInhibitors = 0;
879 double normalLatencyBufferSizeSeconds = 0.0;
880 bool isPreviewEdit =
false;
900 struct ChangedPluginsList;
903 struct EditChangeResetterTimer;
906 SharedLevelMeasurer::Ptr previewLevelMeasurer;
910 friend struct TrackList;
914 void updateTrackStatuses();
915 void updateTrackStatusesAsync();
916 void moveTrackInternal (Track::Ptr, TrackInsertPoint);
919 void initialise (
const Options&);
920 void undoOrRedo (
bool isUndo);
923 void initialiseTempoAndPitch();
925 void initialiseTransport();
926 void initialiseMasterVolume();
927 void initialiseVideo();
928 void initialiseClickTrack();
929 void initialiseTracks (
const Options&);
930 void initialiseAudioDevices();
931 void initialiseRacks();
932 void initialiseMasterPlugins();
933 void initialiseControllerMappings();
934 void initialiseARA();
935 void removeZeroLengthClips();
937 void loadOldTimeSigInfo();
939 void loadOldStyleMarkers();
941 void timerCallback()
override;
943 void readFrozenTracksFiles();
944 void updateFrozenTracks();
945 void needToUpdateFrozenTracks();
947 void sanityCheckTrackNames();
971 void handleAsyncUpdate()
override;
Type get() const noexcept
void stopTimer() noexcept
void startTimer(int intervalInMilliseconds) noexcept
Manages an Ableton Link session connecting an Edit with a number of networked peers,...
A track similar to the MarkerTrack but can be used to move sections of an Edit around.
Stores automation data as it's being read in, and writes it back to the edit when recording finishes.
The Tracktion Edit class!
juce::ValueTree inputDeviceState
The ValueTree of the input device states.
ChordTrack * getChordTrack() const
Returns the global ChordTrack.
static std::unique_ptr< Edit > createEditForPreviewingClip(Clip &)
Creates an Edit for previewing a Clip.
InputDeviceInstance * getCurrentInstanceForInputDevice(InputDevice *) const
Returns an InputDeviceInstance for a global InputDevice.
juce::CachedValue< float > clickTrackGain
The gain of the click track.
static std::unique_ptr< Edit > createEdit(Options)
Creates an Edit for the given options.
VolumeAndPanPlugin::Ptr getMasterVolumePlugin() const
Returns the master VolumeAndPanPlugin.
void restartPlayback()
Use this to tell the play engine to rebuild the audio graph if the toplogy has changed.
juce::ValueTree state
The ValueTree of the Edit state.
static TimeRange getMaximumEditTimeRange()
Returns the maximum length an Edit can be.
juce::ValueTree getAutomapState()
Returns the ValueTree used as the Auotmap state.
void ensureMasterTrack()
Creates a MasterTrack if there isn't currently one.
juce::String getClickTrackDevice() const
Returns the name of the device being used as the click track output.
void setTimecodeOffset(TimeDuration newOffset)
Sets the offset to apply to MIDI timecode.
EditPlaybackContext * getCurrentPlaybackContext() const
Returns the active EditPlaybackContext which is what is attached to the DeviceManager.
ARADocumentHolder & getARADocument()
Returns the ARA document handler.
ArrangerTrack * getArrangerTrack() const
Returns the global ArrangerTrack.
void sendMirrorUpdateToAllPlugins(Plugin &) const
Syncronously updates all Plugins[s] mirroring this one.
juce::CachedValue< TimeDuration > videoOffset
The duration in seconds of the video offset.
ParameterControlMappings & getParameterControlMappings() noexcept
Returns the ParameterControlMappings for the Edit.
TimeRange getClickTrackRange() const noexcept
Returns the range the click track will be audible within.
PitchSequence pitchSequence
The global PitchSequence of this Edit.
std::function< juce::File()> editFileRetriever
This callback can be set to return the file for this Edit.
static std::unique_ptr< Edit > createEditForPreviewingFile(Engine &, const juce::File &, const Edit *editToMatch, bool tryToMatchTempo, bool tryToMatchPitch, bool *couldMatchTempo, juce::ValueTree midiPreviewPlugin, juce::ValueTree midiDrumPreviewPlugin={}, bool forceMidiToDrums=false, std::unique_ptr< Edit > editToUpdate={})
Creates an Edit for previewing a file.
void enableTimecodeSync(bool)
Toggles syncing to MIDI timecode.
void setPreviewLevelMeasurer(SharedLevelMeasurer::Ptr p)
Sets a SharedLevelMeasurer to use.
juce::CachedValue< TimeDuration > masterFadeIn
The duration in seconds of the fade in.
void setLowLatencyDisabledPlugins(const juce::Array< EditItemID > &plugins)
First enables all currently disabled latency plugins and then disables the new set.
Track::Ptr insertTrack(TrackInsertPoint, juce::ValueTree, SelectionManager *)
Inserts a new Track with the given state in the Edit.
TimeDuration getTimecodeOffset() const noexcept
Returns the offset to apply to MIDI timecode.
float getClickTrackVolume() const noexcept
Returns the click track volume.
Engine & engine
The Engine to use.
TransportControl & getTransport() const noexcept
Returns the TransportControl which is used to stop/stop/position playback and recording.
SceneList & getSceneList()
Returns a list of Scenes in the Edit.
void warnOfWastedMidiMessages(InputDevice *, Track *)
Triggers a callback to any registered WastedMidiMessagesListener[s].
EditInputDevices & getEditInputDevices() noexcept
Returns the EditInputDevices for the Edit.
juce::CachedValue< juce::String > lastSignificantChange
The last time a change was made to the Edit.
void sendStartStopMessageToPlugins()
Calls Plugin::playStartedOrStopped to handle automation reacording.
void sendSourceFileUpdate()
Sends a 'sourceMediaChanged' call to all the clips.
CountIn getCountInMode() const
Returns the duration of the count in.
std::atomic< float > progress
Progress will be updated as the Edit loads.
void setEditMetadata(Metadata)
Sets the Metadata for the Edit.
juce::File getVideoFile() const
Returns the currently set video file.
EditRole getEditRole() const noexcept
Returns the EditRole.
EditRole
Enum used to determine what an Edit is being used for.
@ forRendering
Creates an Edit for rendering, not output device playback.
@ forExporting
Creates an Edit for exporting/archiving, not playback/rendering.
@ forExamining
Creates an Edit for examining (listing source files etc).
@ proxiesDisabled
Determines if clips and create proxies.
@ pluginsDisabled
Determines if plugins should be loaded.
@ playDisabled
Determines if an EditPlaybackContext is created.
@ forEditing
Creates an Edit for normal use.
void visitAllAutomatableParams(bool includeTrackParams, const std::function< void(AutomatableParameter &)> &) const
Returns all automatable parameters in an Edit.
void ensureTempoTrack()
Creates a TempoTrack if there isn't currently one.
void setMidiTimecodeIgnoringHours(bool shouldIgnore)
Sets whether hours are ignored when syncing to MIDI timecode.
void deleteTrack(Track *)
Deletes a Track.
LaunchQuantisation & getLaunchQuantisation()
Returns the global launch quantisation.
ParameterChangeHandler & getParameterChangeHandler() noexcept
Returns the ParameterChangeHandler for the Edit.
Edit(Options)
Creates an Edit from a set of Options.
Metadata getEditMetadata()
Returns the current Metadata for the Edit.
void setTimecodeFormat(TimecodeDisplayFormat)
Sets the TimecodeDisplayFormat to use.
juce::CachedValue< bool > clickTrackRecordingOnly
Whether the click track should be audible only when recording.
void setClickTrackOutput(const juce::String &deviceName)
Sets the device to use as the click track output.
TimecodeDisplayFormat getTimecodeFormat() const
Returns the current TimecodeDisplayFormat.
void removeWastedMidiMessagesListener(WastedMidiMessagesListener *)
Removes a previously added WastedMidiMessagesListener.
void setClickTrackRange(TimeRange) noexcept
Sets a range for the click track to be audible within.
void sendTempoOrPitchSequenceChangedUpdates()
Sends a message to all the clips to let them know the tempo or pitch sequence has changed.
TimeDuration getLength() const
Returns the end time of last clip.
bool isTimecodeSyncEnabled() const noexcept
Returns true if syncing to MIDI timecode is enabled.
bool areAnyClipsUsingFile(const AudioFile &)
Returns true if any clips are using this file.
CountIn
An enum to determine the duration of the count in.
@ twoBeat
Two beats count in.
@ oneBeat
One beat count in.
@ none
No count in, play starts immidiately.
@ oneBar
One bar count in.
@ twoBar
Two bars count in.
void ensureMarkerTrack()
Creates a MarkerTrack if there isn't currently one.
void setCurrentMidiMachineControlSource(std::shared_ptr< MidiInputDevice >)
Sets the MidiInputDevice to be used as an MMC source.
void moveTrack(Track::Ptr, TrackInsertPoint)
Moves a track to a new position.
bool areAnyTracksSolo() const
Returns true if any tracks are soloed.
juce::CachedValue< bool > playInStopEnabled
Whether the audio engine should run when playback is stopped.
juce::Array< EditItemID > getLowLatencyDisabledPlugins()
Returns the current set of diabled plugins.
juce::Time getTimeOfLastChange() const
Returns the time the last change occurred.
juce::Array< AutomatableParameter * > getAllAutomatableParams(bool includeTrackParams) const
Returns all automatable parameters in an Edit.
juce::Array< Clip * > findClipsInLinkGroup(juce::String linkGroupID) const
Returns and Clip[s] with the given linkGroupID.
bool shouldPlay() const noexcept
Returns true if this Edit should be played back (or false if it was just opened for inspection).
void removeModifierTimer(ModifierTimer &)
Removes a ModifierTimer previously added.
void setLowLatencyMonitoring(bool enabled, const juce::Array< EditItemID > &plugins)
Toggles low latency monitoring for a set of plugins.
PluginCache & getPluginCache() noexcept
Returns the PluginCache which manages all active Plugin[s] for this Edit.
TrackCompManager & getTrackCompManager() const noexcept
Returns the TrackCompManager for the Edit.
void ensureNumberOfAudioTracks(int minimumNumTracks)
Creates new tracks to ensure the minimum number.
AbletonLink & getAbletonLink() const noexcept
Returns the AbletonLink object.
void setMasterVolumeSliderPos(float)
Sets the master volume level.
juce::String getName()
Returns the name of the Edit if a ProjectItem can be found for it.
juce::ReferenceCountedObjectPtr< FolderTrack > insertNewFolderTrack(TrackInsertPoint, SelectionManager *, bool asSubmix)
Inserts a new FolderTrack in the Edit, optionally as a submix.
void redo()
Redoes the changes undone by the last undo.
juce::CachedValue< ProjectItemID > videoSource
The ProjectItemID of the video source.
AutomationRecordManager & getAutomationRecordManager() noexcept
Returns the AutomationRecordManager for the Edit.
juce::CachedValue< bool > videoMuted
Whether the video source is muted.
void visitAllTopLevelTracks(std::function< bool(Track &)>) const
Visits all top-level tracks (i.e.
std::atomic< bool > shouldExit
Can be set to true to cancel loading the Edit.
juce::ReferenceCountedObjectPtr< AutomationTrack > insertNewAutomationTrack(TrackInsertPoint, SelectionManager *)
Inserts a new AutomationTrack in the Edit.
bool areAnyTracksSoloIsolate() const
Returns true if any tracks are solo isolated.
juce::CachedValue< bool > clickTrackEmphasiseBars
Whether the click track should emphasise bars.
void updateMuteSoloStatuses()
Updates all the tracks and external controller mute/solo statuses.
LoadContext * loadContext
An optional context to be monitor for loading status.
std::shared_ptr< MidiInputDevice > getCurrentMidiMachineControlSource() const
Returns the MidiInputDevice being used as an MMC source.
void cancelAllProxyGeneratorJobs() const
Stops all proxy generator jobs clips may be performing.
juce::CachedValue< TimeDuration > masterFadeOut
The duration in seconds of the fade out.
void setCurrentMidiMachineControlDest(MidiOutputDevice *)
Sets the MidiInputDevice to be used as an MMC destination.
MasterTrack * getMasterTrack() const
Returns the global MasterTrack.
MarkerTrack * getMarkerTrack() const
Returns the global MarkerTrack.
void dispatchPendingUpdatesSynchronously()
If there's a change to send out to the listeners, do it now rather than waiting for the next timer me...
void setProjectItemID(ProjectItemID)
Sets the ProjectItemID of the Edit, this is also stored in the state.
static std::unique_ptr< Edit > createSingleTrackEdit(Engine &, EditRole role=EditRole::forEditing)
Creates an Edit with a single AudioTrack.
juce::CachedValue< bool > midiTimecodeIgnoringHours
Whether the MIDI timecode source ignores hours.
void flushState()
Saves the plugin, automap and ARA states to the state ValueTree.
std::shared_ptr< MidiInputDevice > getCurrentMidiTimecodeSource() const
Returns the MidiInputDevice being used as the MIDI timecode source.
juce::CachedValue< bool > clickTrackEnabled
Whether the click track is enabled.
void setCountInMode(CountIn)
Sets the duration of the count in.
void resetChangedStatus()
Resets the changed status so hasChangedSinceSaved returns false.
int numUndoLevelsToStore
The number of undo levels to use.
void setMasterPanPos(float)
Returns the master pan position.
void pluginChanged(Plugin &) noexcept
Plugins should call this when one of their parameters or state changes to mark the edit as unsaved.
juce::String getSelectableDescription() override
Retuns the description of this Selectable.
MarkerManager & getMarkerManager() const noexcept
Returns the MarkerManager.
SharedLevelMeasurer::Ptr getPreviewLevelMeasurer()
Returns a previously set SharedLevelMeasurer.
void addWastedMidiMessagesListener(WastedMidiMessagesListener *)
Add a WastedMidiMessagesListener to be notified of wasted MIDI messages.
juce::Array< InputDeviceInstance * > getAllInputDevices() const
Returns all the active InputDeviceInstance[s] in the Edit.
bool isRendering() const noexcept
Returns true if the Edit is currently being rendered.
static constexpr double maximumLength
The maximum length an Edit can be.
std::atomic< bool > completed
Set to true once the Edit has loaded.
TrackList & getTrackList()
Returns the TrackList for the Edit which contains all the top level tracks.
TempoSequence tempoSequence
The global TempoSequence of this Edit.
juce::ReferenceCountedObjectPtr< AudioTrack > insertNewAudioTrack(TrackInsertPoint, SelectionManager *)
Inserts a new AudioTrack in the Edit.
void setVideoFile(const juce::File &, juce::String importDesc)
Sets a video file to display.
MacroParameterElement & getGlobalMacros() const
Returns global MacroParameterElement.
bool isLoading() const
Returns true if the Edit's not yet fully loaded.
juce::CachedValue< TimeDuration > timecodeOffset
The duration in seconds of the timecode offset.
void updateMirroredPlugin(Plugin &)
Adds this plugin to a list so mirrored Plugin[s] are updated asyncronously.
void setCurrentMidiTimecodeSource(std::shared_ptr< MidiInputDevice >)
Sets the MidiInputDevice being to be used as the MIDI timecode source.
bool isMidiTimecodeIgnoringHours() const
Returns true if hours are ignored when syncing to MIDI timecode.
ProjectItemID editProjectItemID
The editProjectItemID, must be valid.
void setClickTrackVolume(float gain)
Sets the volume of the click track.
std::function< juce::File(const juce::String &)> filePathResolver
An optional filePathResolver to use.
void ensureArrangerTrack()
Creates an ArrangerTrack if there isn't currently one.
TempoTrack * getTempoTrack() const
Returns the global TempoTrack.
void ensureChordTrack()
Creates a ChordTrack if there isn't currently one.
uint32_t numAudioTracks
If non-zero, will ensure the edit has this many audio tracks.
juce::CachedValue< AudioFadeCurve::Type > masterFadeInType
The curve type of the fade in.
void toggleTimecodeMode()
Toggles the TimecodeDisplayFormat through the available TimecodeType[s].
void invalidateStoredLength() noexcept
Invalidates the stored length so the next call to getLength will update form the Edit contents.
AutomatableParameter::Ptr getMasterSliderPosParameter() const
Returns the master volume AutomatableParameter.
static std::unique_ptr< Edit > createEditForExamining(Engine &, juce::ValueTree, EditRole role=EditRole::forExamining)
Creates an Edit that loads a state, using the role Edit::forExamining.
TimePosition getPreviousTimeOfInterest(TimePosition beforeThisTime)
Finds the previous marker or start/end of a clip after a certain time.
void copyTrack(Track::Ptr, TrackInsertPoint)
Copies a track to a new position.
int getNumCountInBeats() const
Returns the number of beats of the count in.
void visitAllTracksRecursive(std::function< bool(Track &)>) const
Visits all tracks in the Edit with the given function.
void flushPluginStateIfNeeded(Plugin &)
Saves the specified plugin state to the state ValueTree.
void updateMidiTimecodeDevices()
Updates the MIDI timecode/MMC devices.
bool getLowLatencyMonitoring() const noexcept
Returns true if in low latency monitoring mode.
juce::CachedValue< bool > recordingPunchInOut
Whether recoridng only happens within the in/out markers.
static const int ticksPerQuarterNote
The number of ticks per quarter note.
~Edit() override
Destructor.
bool canRenderProxies() const noexcept
Returns true if this Edit can render proxy files.
AutomatableParameter::Ptr getMasterPanParameter() const
Returns the master pan AutomatableParameter.
TimePosition getFirstClipTime() const
Returns the time of first clip.
EditRole role
An optional role to open the Edit with.
EditItemCache< Track > trackCache
Quick way to find and iterate all Track[s] in the Edit.
bool getIsPreviewEdit() const noexcept
Returns true if this Edit is a temporary Edit for previewing files/clips etc.
juce::UndoManager & getUndoManager() noexcept
Returns the juce::UndoManager used for this Edit.
bool hasChangedSinceSaved() const
Returns true if the Edit has changed since it was last saved.
EditItemCache< ClipSlot > clipSlotCache
Quick way to find and iterate all ClipSlot[s] in the Edit.
void setTempDirectory(const juce::File &)
Sets the temp directory for the Edit to use.
static std::unique_ptr< Edit > createEditForPreviewingPreset(Engine &engine, juce::ValueTree, const Edit *editToMatch, bool tryToMatchTempo, bool *couldMatchTempo, juce::ValueTree midiPreviewPlugin, juce::ValueTree midiDrumPreviewPlugin={}, bool forceMidiToDrums=false, std::unique_ptr< Edit > editToUpdate={})
Creates an Edit for previewing a preset.
MidiOutputDevice * getCurrentMidiMachineControlDest() const
Returns the MidiInputDevice being used as an MMC destination.
juce::CachedValue< bool > midiTimecodeSourceDeviceEnabled
Whether a MIDI timecode source is enabled.
EditItemID createNewItemID() const
Returns a new EditItemID to use for a new EditItem.
void undo()
Undoes the most recent changes made.
juce::ValueTree editState
The Edit state.
ProjectItemID getProjectItemID() const noexcept
Returns the ProjectItemID of the Edit.
static int getDefaultNumUndoLevels() noexcept
Returns the default number of undo levels that should be used.
bool shouldLoadPlugins() const noexcept
Returns true if this Edit can load Plugin[s].
bool areAnyTracksMuted() const
Returns true if any tracks are muted.
std::function< juce::File(const juce::String &)> filePathResolver
This callback can be set to resolve file paths.
static TimeDuration getMaximumLength()
Returns the maximum length an Edit can be.
PluginList & getMasterPluginList() const noexcept
Returns the master PluginList.
TimePosition getNextTimeOfInterest(TimePosition afterThisTime)
Finds the next marker or start/end of a clip after a certain time.
void addModifierTimer(ModifierTimer &)
Adds a ModifierTimer to be updated each block.
juce::File getTempDirectory(bool createIfNonExistent) const
Returns the temp directory the Edit it using.
void visitAllTracks(std::function< bool(Track &)>, bool recursive) const
Visits all tracks in the Edit with the given function.
EditItemCache< Clip > clipCache
Quick way to find and iterate all Clip[s] in the Edit.
void initialiseAllPlugins()
Initialises all the plugins.
bool isClickTrackDevice(OutputDevice &) const
Returns true if the given OutputDevice is being used as the click track output.
juce::CachedValue< AudioFadeCurve::Type > masterFadeOutType
The curve type of the fade out.
RackTypeList & getRackList() const noexcept
Returns the RackTypeList which contains all the RackTypes for the Edit.
juce::String getAuxBusName(int bus) const
Returns the name of an aux bus.
void setAuxBusName(int bus, const juce::String &name)
Sets the name of an aux bus.
Track::Ptr insertNewTrack(TrackInsertPoint, const juce::Identifier &xmlType, SelectionManager *)
Inserts a new Track with the given type in the Edit.
void updateModifierTimers(TimePosition editTime, int numSamples) const
Updates all the ModifierTimers with a given edit time and number of samples.
Engine & engine
A reference to the Engine.
std::function< juce::File()> editFileRetriever
An optional editFileRetriever to use.
void markAsChanged()
Marks the edit as being significantly changed and should therefore be saved.
A context passed to the Options struct which will get updated about load process and can be signaled ...
Determines how the Edit will be created.
The Engine is the central class for all tracktion sessions.
Represents a launch quantisation.
Base class for elements which can contain macro parameters.
A track to represent the master plugins.
Base class for audio or midi output devices, to which a track's output can be sent.
Manages a set of AutomatableParameters for an Edit and notifies controllers and registered listeners ...
Controls the set of midi-controller-to-parameter mappings.
Holds a sequence of plugins.
An ID representing one of the items in a Project.
Holds a pointer to some type of Selectable, which automatically becomes null if the selectable is del...
Represents the Scenes in an Edit.
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.
Holds a list of TempoSetting objects, to form a sequence of tempo changes.
A track to represent the "global" items such as tempo, key changes etc.
Base class for tracks which contain clips and plugins and can be added to Edit[s].
Controls the transport of an Edit's playback.
The built-in Tracktion volume/pan plugin.
#define TRANS(stringLiteral)
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Represents a duration in real-life time.
Represents a position in real-life time.
A list of all currently open edits.
Deferred Edit object deleter.
ID for objects of type EditElement - e.g.
Holds the global Macros for the Edit.
Calls an editFinishedLoading method on OwnerType once after the Edit has finished loading.
Temporarily removes an Edit from the device manager, optionally re-adding it on destruction.
Disables the creation of a new transaction.
~UndoTransactionInhibitor()
Destructor.
Interface for classes that need to know about unused MIDI messages.
virtual void warnOfWastedMidiMessages(InputDevice *, Track *)=0
Callback to be notified when a MIDI message isn't used by a track because it doesn't have a plugin wh...
Base class for objects which need to know about the global Edit time every block.
Defines the place to insert Track[s].
An iterable list of Track[s] that live either in an Edit or as subtracks of a Track.