Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
automation_tracklist.h
1// SPDX-FileCopyrightText: © 2018-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __AUDIO_AUTOMATION_TRACKLIST_H__
5#define __AUDIO_AUTOMATION_TRACKLIST_H__
6
7#include "gui/dsp/automation_track.h"
8#include "plugins/plugin_slot.h"
9
10#include <QAbstractListModel>
11
13
14using namespace zrythm;
15
16namespace zrythm::gui
17{
18class Channel;
19}
20
26
31class AutomationTracklist final
32 : public QAbstractListModel,
33 public ICloneable<AutomationTracklist>
34{
35 Q_OBJECT
36 QML_ELEMENT
37
38public:
39 AutomationTracklist (
40 PortRegistry &port_registry,
41 ArrangerObjectRegistry &object_registry,
42 AutomatableTrack &track,
43 QObject * parent = nullptr);
44
45public:
46 enum Roles
47 {
48 AutomationTrackPtrRole = Qt::UserRole + 1,
49 };
50
51 // ========================================================================
52 // QML Interface
53 // ========================================================================
54 QHash<int, QByteArray> roleNames () const override;
55 int rowCount (const QModelIndex &parent = QModelIndex ()) const override;
56 QVariant
57 data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
58
59 Q_INVOKABLE void
60 showNextAvailableAutomationTrack (AutomationTrack * current_automation_track);
61 Q_INVOKABLE void
62 hideAutomationTrack (AutomationTrack * current_automation_track);
63
64 // ========================================================================
65
67 const AutomationTracklist &other,
68 ObjectCloneType clone_type) override;
69
73 [[gnu::cold]] void init_loaded ();
74
75 TrackPtrVariant get_track () const;
76
83
89 void print_ats () const;
90
98 void update_positions (bool from_ticks, bool bpm_change);
99
100 AutomationTrack * get_prev_visible_at (const AutomationTrack &at) const;
101
102 AutomationTrack * get_next_visible_at (const AutomationTrack &at) const;
103
104 void set_at_visible (AutomationTrack &at, bool visible);
105
106 AutomationTrack * get_automation_track_at (size_t index)
107 {
108 return ats_.at (index);
109 }
110
111 auto &get_automation_tracks_in_record_mode () { return ats_in_record_mode_; }
112 auto &get_automation_tracks_in_record_mode () const
113 {
114 return ats_in_record_mode_;
115 }
116
125 AutomationTrack *
126 get_visible_at_after_delta (const AutomationTrack &at, int delta) const;
127
128 int
129 get_visible_at_diff (const AutomationTrack &src, const AutomationTrack &dest)
130 const;
131
140 remove_at (AutomationTrack &at, bool free, bool fire_events);
141
147
152
157 get_automation_track_by_port_id (dsp::PortIdentifier::PortUuid id) const;
158
163
168
180 void set_at_index (AutomationTrack &at, int index, bool push_down);
181
189 int port_index,
190 const utils::Utf8String &symbol);
191
201
202 void append_objects (std::vector<ArrangerObject *> objects) const;
203
207 int get_num_visible () const;
208
215 bool validate () const;
216
220 int get_num_regions () const;
221
222 void print_regions () const;
223
224 auto &get_visible_automation_tracks () { return visible_ats_; }
225 auto &get_visible_automation_tracks () const { return visible_ats_; }
226
227 auto &get_automation_tracks () { return ats_; }
228 auto &get_automation_tracks () const { return ats_; }
229
230 ControlPort &get_port (dsp::PortIdentifier::PortUuid id) const;
231
232 void set_caches (CacheType types);
233
234private:
235 static constexpr std::string_view kAutomationTracksKey = "automationTracks";
236 friend void to_json (nlohmann::json &j, const AutomationTracklist &ats)
237 {
238 j[kAutomationTracksKey] = ats.ats_;
239 }
240 friend void from_json (const nlohmann::json &j, AutomationTracklist &ats);
241
242 auto &get_port_registry () { return port_registry_; }
243 auto &get_port_registry () const { return port_registry_; }
244
245private:
246 ArrangerObjectRegistry &object_registry_;
247 PortRegistry &port_registry_;
248
262 std::vector<AutomationTrack *> ats_;
263
268 std::vector<AutomationTrack *> ats_in_record_mode_;
269
273 std::vector<AutomationTrack *> visible_ats_;
274
278 AutomatableTrack &track_;
279};
280
284
285#endif
Interface for a track that has automatable parameters.
void set_at_index(AutomationTrack &at, int index, bool push_down)
Sets the index of the AutomationTrack and swaps it with the AutomationTrack at that index or pushes t...
void init_after_cloning(const AutomationTracklist &other, ObjectCloneType clone_type) override
Initializes the cloned object.
bool validate() const
Verifies the identifiers on a live automation tracklist (in the project, not a clone).
AutomationTrack * get_automation_track_by_port_id(dsp::PortIdentifier::PortUuid id) const
Returns the AutomationTrack corresponding to the given Port.
void unselect_all()
Unselects all arranger objects.
AutomationTrack * get_first_invisible_at() const
Used when the add button is added and a new automation track is requested to be shown.
AutomationTrack * get_at_from_port(const ControlPort &port) const
Returns the AutomationTrack corresponding to the given Port.
AutomationTrack * add_automation_track(AutomationTrack &at)
Adds the given automation track.
AutomationTrack * get_visible_at_after_delta(const AutomationTrack &at, int delta) const
Returns the AutomationTrack after delta visible AutomationTrack's.
void init_loaded()
Inits a loaded AutomationTracklist.
AutomationTrack * remove_at(AutomationTrack &at, bool free, bool fire_events)
Removes the AutomationTrack from the AutomationTracklist, optionally freeing it.
void update_positions(bool from_ticks, bool bpm_change)
Updates the frames of each position in each child of the automation tracklist recursively.
void clear_objects()
Removes all objects recursively.
int get_num_regions() const
Counts the total number of regions in the automation tracklist.
void remove_channel_ats(gui::Channel *ch)
Removes the AutomationTrack's associated with this channel from the AutomationTracklist in the corres...
AutomationTrack * get_plugin_at(plugins::PluginSlot slot, int port_index, const utils::Utf8String &symbol)
Gets the automation track matching the given arguments.
void print_ats() const
Prints info about all the automation tracks.
int get_num_visible() const
Returns the number of visible AutomationTrack's.
Control port specifics.
Represents a channel strip on the mixer.
Definition channel.h:45
Lightweight UTF-8 string wrapper with safe conversions.
Definition string.h:39
ObjectCloneType
Definition icloneable.h:25