Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
Tracklist Class Referencefinal

The Tracklist contains all the tracks in the Project. More...

#include <src/gui/dsp/tracklist.h>

Inheritance diagram for Tracklist:
Collaboration diagram for Tracklist:

Public Types

enum class  PinOption { PinnedOnly , UnpinnedOnly , Both }
 Used in track search functions. More...
 
enum  TrackRoles { TrackPtrRole = Qt::UserRole + 1 , TrackNameRole }
 
using TrackUuid = Track::Uuid
 

Public Member Functions

 Tracklist (QObject *parent=nullptr)
 
 Tracklist (Project &project, PortRegistry &port_registry, TrackRegistry &track_registry, dsp::PortConnectionsManager *port_connections_manager)
 
 Tracklist (SampleProcessor &sample_processor, PortRegistry &port_registry, TrackRegistry &track_registry, dsp::PortConnectionsManager *port_connections_manager)
 
QHash< int, QByteArray > roleNames () const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
TempoTrackgetTempoTrack () const
 
Q_INVOKABLE void setExclusivelySelectedTrack (QVariant track)
 
auto get_track_span () const
 
bool is_in_active_project () const
 
bool is_auditioner () const
 
void init_after_cloning (const Tracklist &other, ObjectCloneType clone_type) override
 Initializes the cloned object.
 
void init_loaded (PortRegistry &port_registry, Project *project, SampleProcessor *sample_processor)
 Initializes the tracklist when loading a project.
 
void init_loaded (PortRegistry &port_registry, Project &project)
 
void init_loaded (PortRegistry &port_registry, SampleProcessor &sample_processor)
 
TrackPtrVariant insert_track (const TrackUuidReference &track_id, int pos, AudioEngine &engine, bool publish_events, bool recalc_graph)
 Adds given track to given spot in tracklist.
 
TrackPtrVariant append_track (auto track_id, AudioEngine &engine, bool publish_events, bool recalc_graph)
 Calls insert_track with the given options.
 
void remove_track (const TrackUuid &track_id)
 Removes the given track from the tracklist.
 
void move_track (TrackUuid track_id, int pos, bool always_before_pos, std::optional< std::reference_wrapper< Router > > router)
 Moves a track from its current position to the position given by pos.
 
std::optional< TrackPtrVariant > get_track (const TrackUuid &id) const
 
void set_track_pinned (TrackUuid track_id, bool pinned, int publish_events, int recalc_graph)
 Pins or unpins the Track.
 
bool validate () const
 
ChordTrackget_chord_track () const
 
std::optional< TrackPtrVariant > get_first_visible_track (bool pinned) const
 Returns the first visible Track.
 
std::optional< TrackPtrVariant > get_prev_visible_track (Track::TrackUuid track_id) const
 Returns the previous visible Track in the same Tracklist as the given one (ie, pinned or not).
 
std::optional< TrackPtrVariant > get_next_visible_track (Track::TrackUuid track_id) const
 Returns the next visible Track in the same Tracklist as the given one (ie, pinned or not).
 
int get_last_pos (PinOption pin_opt=PinOption::Both, bool visible_only=false) const
 Returns the index of the last Track.
 
std::optional< TrackPtrVariant > get_last_track (PinOption pin_opt=PinOption::Both, bool visible_only=false) const
 Returns the last Track.
 
std::optional< TrackPtrVariant > get_visible_track_after_delta (Track::TrackUuid track_id, int delta) const
 Returns the Track after delta visible Track's.
 
int get_visible_track_diff (Track::TrackUuid src_track, Track::TrackUuid dest_track) const
 Returns the number of visible Tracks between src and dest (negative if dest is before src).
 
bool multiply_track_heights (double multiplier, bool visible_only, bool check_only, bool fire_events)
 Multiplies all tracks' heights and returns if the operation was valid.
 
void handle_click (TrackUuid track_id, bool ctrl, bool shift, bool dragged)
 Handle a click selection.
 
std::vector< ArrangerObjectPtrVariant > get_timeline_objects_in_range (std::optional< std::pair< dsp::Position, dsp::Position > > range=std::nullopt) const
 
void clear_selections_for_object_siblings (const ArrangerObject::Uuid &object_id)
 Clears either the timeline selections or the clip editor selections.
 
void import_regions (std::vector< std::vector< std::shared_ptr< Region > > > &region_arrays, const FileImportInfo *import_info, TracksReadyCallback ready_cb)
 Imports regions from a region array.
 
void move_region_to_track (ArrangerObjectPtrVariant region, const Track::Uuid &to_track_id, int lane_or_at_index, int index)
 Moves the Region to the given Track, maintaining the selection status of the Region.
 
void move_plugin_automation (const Plugin::Uuid &plugin_id, const Track::Uuid &prev_track_id, const Track::Uuid &track_id_to_move_to, zrythm::plugins::PluginSlot new_slot)
 Moves the Plugin's automation from one Channel to another.
 
void move_plugin (const Plugin::Uuid &plugin_id, const Track::Uuid &target_track_id, plugins::PluginSlot slot, bool confirm_overwrite)
 Moves the plugin to the given slot in the given channel.
 
zrythm::gui::Channelget_channel_for_plugin (const Plugin::Uuid &plugin_id)
 
void import_files (std::optional< std::vector< utils::Utf8String > > uri_list, const FileDescriptor *orig_file, const Track *track, const TrackLane *lane, int index, const zrythm::dsp::Position *pos, TracksReadyCallback ready_cb)
 Begins file import Handles a file drop inside the timeline or in empty space in the tracklist.
 
bool track_name_is_unique (const utils::Utf8String &name, TrackUuid track_to_skip) const
 Returns whether the track name is not taken.
 
bool is_track_pinned (size_t index) const
 Returns whether the track at index is pinned.
 
auto get_track_index (const Track::TrackUuid &track_id) const
 
auto get_track_at_index (size_t index) const
 
auto get_track_ref_at_index (size_t index) const
 
bool is_track_pinned (Track::TrackUuid track_id) const
 
auto get_selection_manager ()
 
void select_foldable_children_of_current_selections ()
 Also selects the children of foldable tracks in the currently selected tracks.
 
auto get_pinned_tracks_cutoff_index () const
 
void set_pinned_tracks_cutoff_index (size_t index)
 
auto track_count () const
 
void mark_track_for_bounce (TrackPtrVariant track_var, bool bounce, bool mark_regions, bool mark_children, bool mark_parents)
 Marks the track for bouncing.
 
void mark_all_tracks_for_bounce (bool bounce)
 
- Public Member Functions inherited from ICloneable< Tracklist >
std::unique_ptr< Tracklistclone_unique (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
std::shared_ptr< Tracklistclone_shared (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
Tracklistclone_raw_ptr (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
Tracklistclone_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
QScopedPointer< Tracklistclone_unique_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 

Data Fields

ChordTrackchord_track_ = nullptr
 The chord track, for convenience.
 
MarkerTrackmarker_track_ = nullptr
 The marker track, for convenience.
 
TempoTracktempo_track_ = nullptr
 The tempo track, for convenience.
 
ModulatorTrackmodulator_track_ = nullptr
 The modulator track, for convenience.
 
MasterTrackmaster_track_ = nullptr
 The master track, for convenience.
 
Projectproject_ = nullptr
 Pointer to owner project, if any.
 
QPointer< dsp::PortConnectionsManagerport_connections_manager_
 Width of track widgets.
 
- Data Fields inherited from ICloneable< Tracklist >
friend Derived
 

Static Public Attributes

static constexpr std::array< Track::Type, 4 > unique_track_types_
 A list of track types that must be unique in the tracklist.
 

Properties

QML_ELEMENT TempoTracktempoTrack
 

Friends

void to_json (nlohmann::json &j, const Tracklist &t)
 
void from_json (const nlohmann::json &j, Tracklist &t)
 

Detailed Description

The Tracklist contains all the tracks in the Project.

There should be a clear separation between the Tracklist and the Mixer. The Tracklist should be concerned with Tracks in the arranger, and the Mixer should be concerned with Channels, routing and Port connections.

Definition at line 31 of file tracklist.h.

Member Typedef Documentation

◆ TrackUuid

Definition at line 38 of file tracklist.h.

Member Enumeration Documentation

◆ PinOption

enum class Tracklist::PinOption
strong

Used in track search functions.

Definition at line 43 of file tracklist.h.

◆ TrackRoles

enum Tracklist::TrackRoles

Definition at line 50 of file tracklist.h.

Member Function Documentation

◆ append_track()

TrackPtrVariant Tracklist::append_track ( auto track_id,
AudioEngine & engine,
bool publish_events,
bool recalc_graph )
inline

Calls insert_track with the given options.

Definition at line 140 of file tracklist.h.

◆ clear_selections_for_object_siblings()

void Tracklist::clear_selections_for_object_siblings ( const ArrangerObject::Uuid & object_id)

Clears either the timeline selections or the clip editor selections.

Parameters
object_idThe object that is part of the target selections.

◆ get_first_visible_track()

std::optional< TrackPtrVariant > Tracklist::get_first_visible_track ( bool pinned) const

Returns the first visible Track.

Parameters
pinned1 to check the pinned tracklist, 0 to check the non-pinned tracklist.

◆ get_last_pos()

int Tracklist::get_last_pos ( PinOption pin_opt = PinOption::Both,
bool visible_only = false ) const

Returns the index of the last Track.

Parameters
pin_optPin option.
visible_onlyOnly consider visible Track's.

◆ get_last_track()

std::optional< TrackPtrVariant > Tracklist::get_last_track ( PinOption pin_opt = PinOption::Both,
bool visible_only = false ) const
inline

Returns the last Track.

Parameters
pin_optPin option.
visible_onlyOnly consider visible Track's.

Definition at line 237 of file tracklist.h.

◆ get_pinned_tracks_cutoff_index()

auto Tracklist::get_pinned_tracks_cutoff_index ( ) const
inline

Definition at line 467 of file tracklist.h.

◆ get_selection_manager()

auto Tracklist::get_selection_manager ( )
inline

Definition at line 434 of file tracklist.h.

◆ get_track()

std::optional< TrackPtrVariant > Tracklist::get_track ( const TrackUuid & id) const
inline

Definition at line 173 of file tracklist.h.

◆ get_track_at_index()

auto Tracklist::get_track_at_index ( size_t index) const
inline

Definition at line 415 of file tracklist.h.

◆ get_track_index()

auto Tracklist::get_track_index ( const Track::TrackUuid & track_id) const
inline

Definition at line 408 of file tracklist.h.

◆ get_track_ref_at_index()

auto Tracklist::get_track_ref_at_index ( size_t index) const
inline

Definition at line 422 of file tracklist.h.

◆ get_track_span()

auto Tracklist::get_track_span ( ) const
inline

Definition at line 93 of file tracklist.h.

◆ get_visible_track_after_delta()

std::optional< TrackPtrVariant > Tracklist::get_visible_track_after_delta ( Track::TrackUuid track_id,
int delta ) const

Returns the Track after delta visible Track's.

Negative delta searches backwards.

This function searches tracks only in the same Tracklist as the given one (ie, pinned or not).

◆ get_visible_track_diff()

int Tracklist::get_visible_track_diff ( Track::TrackUuid src_track,
Track::TrackUuid dest_track ) const

Returns the number of visible Tracks between src and dest (negative if dest is before src).

The caller is responsible for checking that both tracks are in the same tracklist (ie, pinned or not).

◆ import_files()

void Tracklist::import_files ( std::optional< std::vector< utils::Utf8String > > uri_list,
const FileDescriptor * orig_file,
const Track * track,
const TrackLane * lane,
int index,
const zrythm::dsp::Position * pos,
TracksReadyCallback ready_cb )

Begins file import Handles a file drop inside the timeline or in empty space in the tracklist.

Parameters
uri_listURI list, if URI list was dropped.
fileFile, if FileDescriptor was dropped.
trackTrack, if any.
laneTrackLane, if any.
indexIndex to insert new tracks at, or -1 to insert at end.
posPosition the file was dropped at, if inside track.
Exceptions
ZrythmExceptionon error.

◆ import_regions()

void Tracklist::import_regions ( std::vector< std::vector< std::shared_ptr< Region > > > & region_arrays,
const FileImportInfo * import_info,
TracksReadyCallback ready_cb )

Imports regions from a region array.

Parameters
region_arrays
import_info
ready_cb
Exceptions
ZrythmExceptionon error.

◆ init_after_cloning()

void Tracklist::init_after_cloning ( const Tracklist & other,
ObjectCloneType clone_type )
overridevirtual

Initializes the cloned object.

Note
Only final classes should implement this.
Exceptions
ZrythmExceptionIf the object could not be cloned.

Implements ICloneable< Tracklist >.

◆ init_loaded() [1/2]

void Tracklist::init_loaded ( PortRegistry & port_registry,
Project & project )
inline

Definition at line 113 of file tracklist.h.

◆ init_loaded() [2/2]

void Tracklist::init_loaded ( PortRegistry & port_registry,
SampleProcessor & sample_processor )
inline

Definition at line 118 of file tracklist.h.

◆ insert_track()

TrackPtrVariant Tracklist::insert_track ( const TrackUuidReference & track_id,
int pos,
AudioEngine & engine,
bool publish_events,
bool recalc_graph )

Adds given track to given spot in tracklist.

Parameters
publish_eventsPublish UI events.
recalc_graphRecalculate routing graph.
Returns
Pointer to the newly added track.

◆ is_auditioner()

bool Tracklist::is_auditioner ( ) const
inline

Definition at line 97 of file tracklist.h.

◆ is_track_pinned() [1/2]

bool Tracklist::is_track_pinned ( size_t index) const
inline

Returns whether the track at index is pinned.

Definition at line 403 of file tracklist.h.

◆ is_track_pinned() [2/2]

bool Tracklist::is_track_pinned ( Track::TrackUuid track_id) const
inline

Definition at line 429 of file tracklist.h.

◆ mark_all_tracks_for_bounce()

void Tracklist::mark_all_tracks_for_bounce ( bool bounce)
inline

Definition at line 489 of file tracklist.h.

◆ mark_track_for_bounce()

void Tracklist::mark_track_for_bounce ( TrackPtrVariant track_var,
bool bounce,
bool mark_regions,
bool mark_children,
bool mark_parents )

Marks the track for bouncing.

Parameters
mark_childrenWhether to mark all children tracks as well. Used when exporting stems on the specific track stem only. IMPORTANT: Track.bounce_to_master must be set beforehand if this is true.
mark_parentsWhether to mark all parent tracks as well.

◆ move_plugin()

void Tracklist::move_plugin ( const Plugin::Uuid & plugin_id,
const Track::Uuid & target_track_id,
plugins::PluginSlot slot,
bool confirm_overwrite )

Moves the plugin to the given slot in the given channel.

If a plugin already exists, it deletes it and replaces it.

Parameters
confirm_overwriteWhether to show a dialog to confirm the overwrite when a plugin already exists.

◆ move_region_to_track()

void Tracklist::move_region_to_track ( ArrangerObjectPtrVariant region,
const Track::Uuid & to_track_id,
int lane_or_at_index,
int index )

Moves the Region to the given Track, maintaining the selection status of the Region.

Assumes that the Region is already in a TrackLane or AutomationTrack.

Parameters
lane_or_at_indexIf MIDI or audio, lane position. If automation, automation track index in the automation tracklist. If -1, the track lane or automation track index will be inferred from the region.
indexIf MIDI or audio, index in lane in the new track to insert the region to, or -1 to append. If automation, index in the automation track.
Exceptions
ZrythmExceptionon error.

◆ move_track()

void Tracklist::move_track ( TrackUuid track_id,
int pos,
bool always_before_pos,
std::optional< std::reference_wrapper< Router > > router )

Moves a track from its current position to the position given by pos.

Parameters
posPosition to insert at, or -1 to insert at the end.
always_before_posWhether the track should always be put before the track currently at pos. If this is true, when moving down, the resulting track position will be pos - 1.
routerIf given, the processing graph will be soft-recalculated.

◆ multiply_track_heights()

bool Tracklist::multiply_track_heights ( double multiplier,
bool visible_only,
bool check_only,
bool fire_events )

Multiplies all tracks' heights and returns if the operation was valid.

Parameters
visible_onlyOnly apply to visible tracks.

◆ remove_track()

void Tracklist::remove_track ( const TrackUuid & track_id)

Removes the given track from the tracklist.

Also disconnects the channel (breaks its internal & external connections) and removes any plugins (if any).

◆ select_foldable_children_of_current_selections()

void Tracklist::select_foldable_children_of_current_selections ( )
inline

Also selects the children of foldable tracks in the currently selected tracks.

Definition at line 443 of file tracklist.h.

◆ set_pinned_tracks_cutoff_index()

void Tracklist::set_pinned_tracks_cutoff_index ( size_t index)
inline

Definition at line 468 of file tracklist.h.

◆ track_count()

auto Tracklist::track_count ( ) const
inline

Definition at line 472 of file tracklist.h.

◆ track_name_is_unique()

bool Tracklist::track_name_is_unique ( const utils::Utf8String & name,
TrackUuid track_to_skip ) const

Returns whether the track name is not taken.

Parameters
track_to_skipTrack to skip when searching.

Friends And Related Symbol Documentation

◆ from_json

void from_json ( const nlohmann::json & j,
Tracklist & t )
friend

Definition at line 506 of file tracklist.h.

◆ to_json

void to_json ( nlohmann::json & j,
const Tracklist & t )
friend

Definition at line 498 of file tracklist.h.

Field Documentation

◆ chord_track_

ChordTrack* Tracklist::chord_track_ = nullptr

The chord track, for convenience.

Definition at line 551 of file tracklist.h.

◆ marker_track_

MarkerTrack* Tracklist::marker_track_ = nullptr

The marker track, for convenience.

Definition at line 554 of file tracklist.h.

◆ master_track_

MasterTrack* Tracklist::master_track_ = nullptr

The master track, for convenience.

Definition at line 563 of file tracklist.h.

◆ modulator_track_

ModulatorTrack* Tracklist::modulator_track_ = nullptr

The modulator track, for convenience.

Definition at line 560 of file tracklist.h.

◆ port_connections_manager_

QPointer<dsp::PortConnectionsManager> Tracklist::port_connections_manager_

Width of track widgets.

Definition at line 587 of file tracklist.h.

◆ project_

Project* Tracklist::project_ = nullptr

Pointer to owner project, if any.

Definition at line 582 of file tracklist.h.

◆ tempo_track_

TempoTrack* Tracklist::tempo_track_ = nullptr

The tempo track, for convenience.

Definition at line 557 of file tracklist.h.

◆ unique_track_types_

std::array<Track::Type, 4> Tracklist::unique_track_types_
staticconstexpr
Initial value:
= {
}
@ Marker
Marker Track's contain named markers at specific Position's in the song.
Definition track.h:328
@ Modulator
Special track to contain global Modulator's.
Definition track.h:338
@ Tempo
Special track for BPM (tempo) and time signature events.
Definition track.h:333
@ Chord
The chord track contains chords that can be used to modify midi in real time or to color the piano ro...
Definition track.h:323

A list of track types that must be unique in the tracklist.

Definition at line 88 of file tracklist.h.

Property Documentation

◆ tempoTrack

QML_ELEMENT TempoTrack * Tracklist::tempoTrack
read

Definition at line 35 of file tracklist.h.


The documentation for this class was generated from the following file: