Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
The Tracklist contains all the tracks in the Project. More...
#include <src/structure/tracks/tracklist.h>
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. | |
ChordTrack * | get_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. | |
AutomationTrack * | get_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 > > > ®ion_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. | |
Channel * | get_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 | |
ChordTrack * | chord_track_ = nullptr |
The chord track, for convenience. | |
MarkerTrack * | marker_track_ = nullptr |
The marker track, for convenience. | |
ModulatorTrack * | modulator_track_ = nullptr |
The modulator track, for convenience. | |
MasterTrack * | master_track_ = nullptr |
The master track, for convenience. | |
Project * | project_ = nullptr |
Pointer to owner project, if any. | |
QPointer< dsp::PortConnectionsManager > | port_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) |
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.
Definition at line 47 of file tracklist.h.
using zrythm::structure::tracks::Tracklist::ArrangerObjectPtrVariant = arrangement::ArrangerObjectPtrVariant |
Definition at line 45 of file tracklist.h.
Definition at line 46 of file tracklist.h.
Definition at line 44 of file tracklist.h.
|
strong |
Used in track search functions.
Definition at line 52 of file tracklist.h.
enum zrythm::structure::tracks::Tracklist::TrackRoles |
Definition at line 59 of file tracklist.h.
|
inline |
Calls insert_track with the given options.
Definition at line 145 of file tracklist.h.
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.
object_id | The object that is part of the target selections. |
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.
std::optional< TrackPtrVariant > zrythm::structure::tracks::Tracklist::get_first_visible_track | ( | bool | pinned | ) | const |
Returns the first visible Track.
pinned | 1 to check the pinned tracklist, 0 to check the non-pinned tracklist. |
int zrythm::structure::tracks::Tracklist::get_last_pos | ( | PinOption | pin_opt = PinOption::Both, |
bool | visible_only = false ) const |
|
inline |
Returns the last Track.
pin_opt | Pin option. |
visible_only | Only consider visible Track's. |
Definition at line 240 of file tracklist.h.
|
inline |
Definition at line 478 of file tracklist.h.
|
inline |
Definition at line 445 of file tracklist.h.
|
inline |
Definition at line 178 of file tracklist.h.
|
inline |
Definition at line 426 of file tracklist.h.
|
inline |
Definition at line 419 of file tracklist.h.
|
inline |
Definition at line 433 of file tracklist.h.
|
inline |
Definition at line 100 of file tracklist.h.
std::optional< TrackPtrVariant > zrythm::structure::tracks::Tracklist::get_visible_track_after_delta | ( | Track::TrackUuid | track_id, |
int | delta ) const |
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).
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.
uri_list | URI list, if URI list was dropped. |
file | File, if FileDescriptor was dropped. |
track | Track, if any. |
lane | TrackLane, if any. |
index | Index to insert new tracks at, or -1 to insert at end. |
pos | Position the file was dropped at, if inside track. |
ZrythmException | on error. |
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.
region_arrays | |
import_info | |
ready_cb |
ZrythmException | on error. |
|
inline |
Definition at line 121 of file tracklist.h.
|
inline |
Definition at line 117 of file tracklist.h.
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.
publish_events | Publish UI events. |
recalc_graph | Recalculate routing graph. |
|
inline |
Definition at line 102 of file tracklist.h.
|
inline |
Returns whether the track at index
is pinned.
Definition at line 414 of file tracklist.h.
|
inline |
Definition at line 440 of file tracklist.h.
|
inline |
Definition at line 500 of file tracklist.h.
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.
mark_children | Whether 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_parents | Whether to mark all parent tracks as well. |
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.
confirm_overwrite | Whether to show a dialog to confirm the overwrite when a plugin already exists. |
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.
lane_or_at_index | If 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. |
index | If 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. |
ZrythmException | on error. |
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
.
pos | Position to insert at, or -1 to insert at the end. |
always_before_pos | Whether 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. |
router | If given, the processing graph will be soft-recalculated. |
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.
visible_only | Only apply to visible tracks. |
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).
|
inline |
Also selects the children of foldable tracks in the currently selected tracks.
Definition at line 454 of file tracklist.h.
|
inline |
Definition at line 479 of file tracklist.h.
|
inline |
Definition at line 483 of file tracklist.h.
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.
track_to_skip | Track to skip when searching. |
|
friend |
Definition at line 521 of file tracklist.h.
|
friend |
Definition at line 513 of file tracklist.h.
ChordTrack* zrythm::structure::tracks::Tracklist::chord_track_ = nullptr |
The chord track, for convenience.
Definition at line 602 of file tracklist.h.
MarkerTrack* zrythm::structure::tracks::Tracklist::marker_track_ = nullptr |
The marker track, for convenience.
Definition at line 605 of file tracklist.h.
MasterTrack* zrythm::structure::tracks::Tracklist::master_track_ = nullptr |
The master track, for convenience.
Definition at line 611 of file tracklist.h.
ModulatorTrack* zrythm::structure::tracks::Tracklist::modulator_track_ = nullptr |
The modulator track, for convenience.
Definition at line 608 of file tracklist.h.
QPointer<dsp::PortConnectionsManager> zrythm::structure::tracks::Tracklist::port_connections_manager_ |
Width of track widgets.
Definition at line 642 of file tracklist.h.
Project* zrythm::structure::tracks::Tracklist::project_ = nullptr |
Pointer to owner project, if any.
Definition at line 637 of file tracklist.h.
|
staticconstexpr |
A list of track types that must be unique in the tracklist.
Definition at line 96 of file tracklist.h.