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

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

#include <src/structure/tracks/tracklist.h>

Inheritance diagram for zrythm::structure::tracks::Tracklist:
Collaboration diagram for zrythm::structure::tracks::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
 
using ArrangerObjectPtrVariant = arrangement::ArrangerObjectPtrVariant
 
using Region = arrangement::Region
 
using ArrangerObject = arrangement::ArrangerObject
 

Public Member Functions

 Tracklist (Project &project, PortRegistry &port_registry, TrackRegistry &track_registry, dsp::PortConnectionsManager &port_connections_manager, const dsp::TempoMap &tempo_map)
 
 Tracklist (engine::session::SampleProcessor &sample_processor, PortRegistry &port_registry, TrackRegistry &track_registry, dsp::PortConnectionsManager &port_connections_manager, const dsp::TempoMap &tempo_map)
 
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
 
Q_INVOKABLE void setExclusivelySelectedTrack (QVariant track)
 
auto get_track_span () const
 
bool is_auditioner () const
 
void init_loaded (PortRegistry &port_registry, Project *project, engine::session::SampleProcessor *sample_processor)
 Initializes the tracklist when loading a project.
 
void init_loaded (PortRegistry &port_registry, Project &project)
 
void init_loaded (PortRegistry &port_registry, engine::session::SampleProcessor &sample_processor)
 
TrackPtrVariant insert_track (const TrackUuidReference &track_id, int pos, engine::device_io::AudioEngine &engine, bool publish_events, bool recalc_graph)
 Adds given track to given spot in tracklist.
 
TrackPtrVariant append_track (auto track_id, engine::device_io::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< engine::session::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.
 
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.
 
AutomationTrackget_automation_track_for_port (const Port::Uuid &port_id) const
 Gets the automation track for a port.
 
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.
 
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)
 
void disconnect_plugin (const Plugin::Uuid &plugin_id)
 
std::string print_port_connection (const dsp::PortConnection &conn) const
 
void disconnect_fader (Fader &fader)
 Disconnects all ports connected to the fader.
 

Data Fields

ChordTrackchord_track_ = nullptr
 The chord track, for convenience.
 
MarkerTrackmarker_track_ = nullptr
 The marker 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.
 

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.
 

Friends

void init_from (Tracklist &obj, const Tracklist &other, utils::ObjectCloneType clone_type)
 
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 38 of file tracklist.h.

Member Typedef Documentation

◆ ArrangerObject

◆ ArrangerObjectPtrVariant

using zrythm::structure::tracks::Tracklist::ArrangerObjectPtrVariant = arrangement::ArrangerObjectPtrVariant

Definition at line 45 of file tracklist.h.

◆ Region

◆ TrackUuid

Member Enumeration Documentation

◆ PinOption

Used in track search functions.

Definition at line 52 of file tracklist.h.

◆ TrackRoles

enum zrythm::structure::tracks::Tracklist::TrackRoles

Definition at line 59 of file tracklist.h.

Member Function Documentation

◆ append_track()

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

Calls insert_track with the given options.

Definition at line 145 of file tracklist.h.

◆ clear_selections_for_object_siblings()

void zrythm::structure::tracks::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_automation_track_for_port()

AutomationTrack * zrythm::structure::tracks::Tracklist::get_automation_track_for_port ( const Port::Uuid & port_id) const

Gets the automation track for a port.

This is optimized via a lookup table.

◆ get_first_visible_track()

std::optional< TrackPtrVariant > zrythm::structure::tracks::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 zrythm::structure::tracks::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 > zrythm::structure::tracks::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 240 of file tracklist.h.

◆ get_pinned_tracks_cutoff_index()

auto zrythm::structure::tracks::Tracklist::get_pinned_tracks_cutoff_index ( ) const
inline

Definition at line 478 of file tracklist.h.

◆ get_selection_manager()

auto zrythm::structure::tracks::Tracklist::get_selection_manager ( )
inline

Definition at line 445 of file tracklist.h.

◆ get_track()

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

Definition at line 178 of file tracklist.h.

◆ get_track_at_index()

auto zrythm::structure::tracks::Tracklist::get_track_at_index ( size_t index) const
inline

Definition at line 426 of file tracklist.h.

◆ get_track_index()

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

Definition at line 419 of file tracklist.h.

◆ get_track_ref_at_index()

auto zrythm::structure::tracks::Tracklist::get_track_ref_at_index ( size_t index) const
inline

Definition at line 433 of file tracklist.h.

◆ get_track_span()

auto zrythm::structure::tracks::Tracklist::get_track_span ( ) const
inline

Definition at line 100 of file tracklist.h.

◆ get_visible_track_after_delta()

std::optional< TrackPtrVariant > zrythm::structure::tracks::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 zrythm::structure::tracks::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 zrythm::structure::tracks::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 zrythm::structure::tracks::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_loaded() [1/2]

void zrythm::structure::tracks::Tracklist::init_loaded ( PortRegistry & port_registry,
engine::session::SampleProcessor & sample_processor )
inline

Definition at line 121 of file tracklist.h.

◆ init_loaded() [2/2]

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

Definition at line 117 of file tracklist.h.

◆ insert_track()

TrackPtrVariant zrythm::structure::tracks::Tracklist::insert_track ( const TrackUuidReference & track_id,
int pos,
engine::device_io::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 zrythm::structure::tracks::Tracklist::is_auditioner ( ) const
inline

Definition at line 102 of file tracklist.h.

◆ is_track_pinned() [1/2]

bool zrythm::structure::tracks::Tracklist::is_track_pinned ( size_t index) const
inline

Returns whether the track at index is pinned.

Definition at line 414 of file tracklist.h.

◆ is_track_pinned() [2/2]

bool zrythm::structure::tracks::Tracklist::is_track_pinned ( Track::TrackUuid track_id) const
inline

Definition at line 440 of file tracklist.h.

◆ mark_all_tracks_for_bounce()

void zrythm::structure::tracks::Tracklist::mark_all_tracks_for_bounce ( bool bounce)
inline

Definition at line 500 of file tracklist.h.

◆ mark_track_for_bounce()

void zrythm::structure::tracks::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 zrythm::structure::tracks::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 zrythm::structure::tracks::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 zrythm::structure::tracks::Tracklist::move_track ( TrackUuid track_id,
int pos,
bool always_before_pos,
std::optional< std::reference_wrapper< engine::session::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 zrythm::structure::tracks::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 zrythm::structure::tracks::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 zrythm::structure::tracks::Tracklist::select_foldable_children_of_current_selections ( )
inline

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

Definition at line 454 of file tracklist.h.

◆ set_pinned_tracks_cutoff_index()

void zrythm::structure::tracks::Tracklist::set_pinned_tracks_cutoff_index ( size_t index)
inline

Definition at line 479 of file tracklist.h.

◆ track_count()

auto zrythm::structure::tracks::Tracklist::track_count ( ) const
inline

Definition at line 483 of file tracklist.h.

◆ track_name_is_unique()

bool zrythm::structure::tracks::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 521 of file tracklist.h.

◆ to_json

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

Definition at line 513 of file tracklist.h.

Field Documentation

◆ chord_track_

ChordTrack* zrythm::structure::tracks::Tracklist::chord_track_ = nullptr

The chord track, for convenience.

Definition at line 602 of file tracklist.h.

◆ marker_track_

MarkerTrack* zrythm::structure::tracks::Tracklist::marker_track_ = nullptr

The marker track, for convenience.

Definition at line 605 of file tracklist.h.

◆ master_track_

MasterTrack* zrythm::structure::tracks::Tracklist::master_track_ = nullptr

The master track, for convenience.

Definition at line 611 of file tracklist.h.

◆ modulator_track_

ModulatorTrack* zrythm::structure::tracks::Tracklist::modulator_track_ = nullptr

The modulator track, for convenience.

Definition at line 608 of file tracklist.h.

◆ port_connections_manager_

QPointer<dsp::PortConnectionsManager> zrythm::structure::tracks::Tracklist::port_connections_manager_

Width of track widgets.

Definition at line 642 of file tracklist.h.

◆ project_

Project* zrythm::structure::tracks::Tracklist::project_ = nullptr

Pointer to owner project, if any.

Definition at line 637 of file tracklist.h.

◆ unique_track_types_

std::array<Track::Type, 4> zrythm::structure::tracks::Tracklist::unique_track_types_
staticconstexpr
Initial value:
= {
}
@ Marker
Marker Track's contain named markers at specific Position's in the song.
Definition track.h:326
@ Modulator
Special track to contain global Modulator's.
Definition track.h:331
@ 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:321

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

Definition at line 96 of file tracklist.h.


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