Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
channel_track.h
1// SPDX-FileCopyrightText: © 2018-2019, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "structure/tracks/channel.h"
7#include "structure/tracks/processable_track.h"
8
9#define DEFINE_CHANNEL_TRACK_QML_PROPERTIES(ClassType) \
10public: \
11 Q_PROPERTY (Channel * channel READ channel CONSTANT)
12
13namespace zrythm::structure::tracks
14{
18class ChannelTrack : virtual public ProcessableTrack
19{
20protected:
21 ChannelTrack (FinalTrackDependencies dependencies);
22
23public:
24 ~ChannelTrack () override = default;
25
26 Channel * channel () const { return channel_.get (); }
27
31 bool currently_muted () const override
32 {
33 return channel_->get_fader ().currently_muted ();
34 }
35
39 bool currently_listened () const override
40 {
41 return channel_->get_fader ().currently_listened ();
42 }
43
49 bool get_implied_soloed () const override;
50
51 bool currently_soloed () const override
52 {
53 return channel_->get_fader ().currently_soloed ();
54 }
55
60 // GMenu * generate_channel_context_menu ();
61
72 bool listen,
73 bool trigger_undo,
74 bool auto_select,
75 bool fire_events);
76
86 void
87 set_soloed (bool solo, bool trigger_undo, bool auto_select, bool fire_events);
88
92 void
93 set_muted (bool mute, bool trigger_undo, bool auto_select, bool fire_events);
94
95 void set_output (std::optional<Track::Uuid> id) { output_track_uuid_ = id; }
96
97 bool has_output () const { return output_track_uuid_.has_value (); }
98
99 auto output_track () const
100 {
101 return track_registry_.find_by_id_or_throw (output_track_uuid_.value ());
102 }
103
104 GroupTargetTrack &output_track_as_group_target () const;
105
106protected:
107 friend void init_from (
108 ChannelTrack &obj,
109 const ChannelTrack &other,
110 utils::ObjectCloneType clone_type);
111
118
119private:
120 static constexpr auto kChannelKey = "channel"sv;
121 static constexpr auto kOutputIdKey = "outputId"sv;
122 friend void to_json (nlohmann::json &j, const ChannelTrack &c)
123 {
124 j[kChannelKey] = c.channel_;
125 j[kOutputIdKey] = c.output_track_uuid_;
126 }
127 friend void from_json (const nlohmann::json &j, ChannelTrack &c)
128 {
129 c.channel_ = c.generate_channel ();
130 j.at (kChannelKey).get_to (*c.channel_);
131 j.at (kOutputIdKey).get_to (c.output_track_uuid_);
132 }
133
134 utils::QObjectUniquePtr<Channel> generate_channel ();
135
136private:
141
143 std::optional<Uuid> output_track_uuid_;
144
145 TrackRegistry &track_registry_;
146};
147
148using ChannelTrackVariant = std::variant<
149 AudioBusTrack,
150 AudioTrack,
151 ChordTrack,
152 MidiBusTrack,
153 MidiTrack,
154 AudioGroupTrack,
155 MidiGroupTrack,
156 InstrumentTrack,
157 MasterTrack>;
158using ChannelTrackPtrVariant = to_pointer_variant<ChannelTrackVariant>;
159
160} // namespace zrythm::structure::tracks
Abstract class for a track that has a channel in the mixer.
void init_channel()
Initializes the channel.
bool currently_muted() const override
Returns if the track is muted.
void set_soloed(bool solo, bool trigger_undo, bool auto_select, bool fire_events)
Sets track soloed, updates UI and optionally adds the action to the undo stack.
bool get_implied_soloed() const override
Returns whether the fader is not soloed on its own but its direct out (or its direct out's direct out...
bool currently_listened() const override
Returns if the track is listened.
void set_muted(bool mute, bool trigger_undo, bool auto_select, bool fire_events)
Sets track muted and optionally adds the action to the undo stack.
void set_listened(bool listen, bool trigger_undo, bool auto_select, bool fire_events)
Generates a menu to be used for channel-related items, eg, fader buttons, direct out,...
Represents a channel strip on the mixer.
Definition channel.h:57
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:40