Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
channel_send_action.h
1// SPDX-FileCopyrightText: © 2020-2021, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/port_connections_manager.h"
7#include "gui/backend/backend/actions/undoable_action.h"
8#include "structure/tracks/channel_send.h"
9
10namespace zrythm::gui::actions
11{
12
16class ChannelSendAction : public QObject, public UndoableAction
17{
18 Q_OBJECT
19 QML_ELEMENT
20 DEFINE_UNDOABLE_ACTION_QML_PROPERTIES (ChannelSendAction)
21
22 using ChannelSend = structure::tracks::ChannelSend;
23
24public:
25 enum class Type
26 {
27 ConnectStereo,
28 ConnectMidi,
29 ConnectSidechain,
30 ChangeAmount,
31 ChangePorts,
32 Disconnect,
33 };
34
35 using PortType = zrythm::dsp::PortType;
36
37public:
38 ChannelSendAction (QObject * parent = nullptr);
39
49 Type type,
50 const ChannelSend &send,
51 const dsp::Port * port,
52 std::optional<std::pair<const dsp::AudioPort &, const dsp::AudioPort &>>
53 stereo,
54 float amount,
55 const dsp::PortConnectionsManager * port_connections_mgr);
56
57 QString to_string () const override;
58
59 friend void init_from (
60 ChannelSendAction &obj,
61 const ChannelSendAction &other,
62 utils::ObjectCloneType clone_type);
63
64private:
65 void init_loaded_impl () override { }
66 void perform_impl () override;
67 void undo_impl () override;
68
69 bool connect_or_disconnect (bool connect, bool do_it);
70
71public:
72 std::unique_ptr<ChannelSend> send_before_;
73
74 float amount_ = 0.f;
75
77 std::optional<dsp::PortUuid> l_id_;
78 std::optional<dsp::PortUuid> r_id_;
79 std::optional<dsp::PortUuid> midi_id_;
80
83};
84
85class ChannelSendDisconnectAction final : public ChannelSendAction
86{
87public:
88 ChannelSendDisconnectAction (
89 const ChannelSend &send,
90 const dsp::PortConnectionsManager &port_connections_mgr)
91 : ChannelSendAction (Type::Disconnect, send, nullptr, std::nullopt, 0.f, &port_connections_mgr)
92 {
93 }
94};
95
96class ChannelSendConnectMidiAction final : public ChannelSendAction
97{
98public:
99 ChannelSendConnectMidiAction (
100 const ChannelSend &send,
101 const dsp::Port &midi,
102 const dsp::PortConnectionsManager &port_connections_mgr)
103 : ChannelSendAction (Type::ConnectMidi, send, &midi, std::nullopt, 0.f, &port_connections_mgr)
104 {
105 }
106};
107
108class ChannelSendConnectStereoAction final : public ChannelSendAction
109{
110public:
111 ChannelSendConnectStereoAction (
112 const ChannelSend &send,
113 std::pair<const dsp::AudioPort &, const dsp::AudioPort &> stereo,
114 const dsp::PortConnectionsManager &port_connections_mgr)
115 : ChannelSendAction (Type::ConnectStereo, send, nullptr, stereo, 0.f, &port_connections_mgr)
116 {
117 }
118};
119
120class ChannelSendConnectSidechainAction final : public ChannelSendAction
121{
122public:
123 ChannelSendConnectSidechainAction (
124 const ChannelSend &send,
125 std::pair<const dsp::AudioPort &, const dsp::AudioPort &> sidechain,
126 const dsp::PortConnectionsManager &port_connections_mgr)
127 : ChannelSendAction (
128 Type::ConnectSidechain,
129 send,
130 nullptr,
131 sidechain,
132 0.f,
133 &port_connections_mgr)
134 {
135 }
136};
137
138class ChannelSendChangeAmountAction final : public ChannelSendAction
139{
140public:
141 ChannelSendChangeAmountAction (const ChannelSend &send, float amount)
142 : ChannelSendAction (Type::ChangeAmount, send, nullptr, std::nullopt, amount, nullptr)
143 {
144 }
145};
146
147}; // namespace zrythm::gui::actions
A base class for ports used for connecting processors in the DSP graph.
Definition port.h:30
std::optional< dsp::PortUuid > l_id_
Target port identifiers.
ChannelSendAction(Type type, const ChannelSend &send, const dsp::Port *port, std::optional< std::pair< const dsp::AudioPort &, const dsp::AudioPort & > > stereo, float amount, const dsp::PortConnectionsManager *port_connections_mgr)
Creates a new action.
QString to_string() const override
Stringizes the action to be used in Undo/Redo buttons.