Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
channel_send_action.h
1// SPDX-FileCopyrightText: © 2020-2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __UNDO_CHANNEL_SEND_ACTION_H__
5#define __UNDO_CHANNEL_SEND_ACTION_H__
6
8#include "dsp/channel_send.h"
10
17enum class ChannelSendActionType
18{
19 CHANNEL_SEND_ACTION_CONNECT_STEREO,
20 CHANNEL_SEND_ACTION_CONNECT_MIDI,
21 CHANNEL_SEND_ACTION_CONNECT_SIDECHAIN,
22 CHANNEL_SEND_ACTION_CHANGE_AMOUNT,
23 CHANNEL_SEND_ACTION_CHANGE_PORTS,
24 CHANNEL_SEND_ACTION_DISCONNECT,
25};
26
30typedef struct ChannelSendAction
31{
32 UndoableAction parent_instance;
33
34 ChannelSend * send_before;
35
36 float amount;
37
40 PortIdentifier * r_id;
41 PortIdentifier * midi_id;
42
46
50
52 ChannelSendActionType type;
53
55
56void
57channel_send_action_init_loaded (ChannelSendAction * self);
58
67WARN_UNUSED_RESULT UndoableAction *
69 ChannelSend * send,
70 ChannelSendActionType type,
71 Port * port,
72 StereoPorts * stereo,
73 float amount,
74 const PortConnectionsManager * port_connections_mgr,
75 GError ** error);
76
77#define channel_send_action_new_disconnect(send, error) \
78 channel_send_action_new ( \
79 send, ChannelSendActionType::CHANNEL_SEND_ACTION_DISCONNECT, NULL, NULL, \
80 0.f, PORT_CONNECTIONS_MGR, error)
81
82#define channel_send_action_new_connect_midi(send, midi, error) \
83 channel_send_action_new ( \
84 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CONNECT_MIDI, midi, NULL, \
85 0.f, PORT_CONNECTIONS_MGR, error)
86
87#define channel_send_action_new_connect_audio(send, stereo, error) \
88 channel_send_action_new ( \
89 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CONNECT_STEREO, NULL, \
90 stereo, 0.f, PORT_CONNECTIONS_MGR, error)
91
92#define channel_send_action_new_connect_sidechain(send, stereo, error) \
93 channel_send_action_new ( \
94 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CONNECT_SIDECHAIN, NULL, \
95 stereo, 0.f, PORT_CONNECTIONS_MGR, error)
96
97#define channel_send_action_new_change_amount(send, amt, error) \
98 channel_send_action_new ( \
99 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CHANGE_AMOUNT, NULL, \
100 NULL, amt, NULL, error)
101
102NONNULL ChannelSendAction *
103channel_send_action_clone (const ChannelSendAction * src);
104
111bool
113 ChannelSend * send,
114 ChannelSendActionType type,
115 Port * port,
116 StereoPorts * stereo,
117 float amount,
118 const PortConnectionsManager * port_connections_mgr,
119 GError ** error);
120
121#define channel_send_action_perform_disconnect(send, error) \
122 channel_send_action_perform ( \
123 send, ChannelSendActionType::CHANNEL_SEND_ACTION_DISCONNECT, NULL, NULL, \
124 0.f, PORT_CONNECTIONS_MGR, error)
125
126#define channel_send_action_perform_connect_midi(send, midi, error) \
127 channel_send_action_perform ( \
128 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CONNECT_MIDI, midi, NULL, \
129 0.f, PORT_CONNECTIONS_MGR, error)
130
131#define channel_send_action_perform_connect_audio(send, stereo, error) \
132 channel_send_action_perform ( \
133 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CONNECT_STEREO, NULL, \
134 stereo, 0.f, PORT_CONNECTIONS_MGR, error)
135
136#define channel_send_action_perform_connect_sidechain(send, stereo, error) \
137 channel_send_action_perform ( \
138 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CONNECT_SIDECHAIN, NULL, \
139 stereo, 0.f, PORT_CONNECTIONS_MGR, error)
140
141#define channel_send_action_perform_change_amount(send, amt, error) \
142 channel_send_action_perform ( \
143 send, ChannelSendActionType::CHANNEL_SEND_ACTION_CHANGE_AMOUNT, NULL, \
144 NULL, amt, NULL, error)
145
146int
147channel_send_action_do (ChannelSendAction * self, GError ** error);
148
149int
150channel_send_action_undo (ChannelSendAction * self, GError ** error);
151
152char *
153channel_send_action_stringize (ChannelSendAction * self);
154
155void
156channel_send_action_free (ChannelSendAction * self);
157
162#endif
Channel send.
WARN_UNUSED_RESULT UndoableAction * channel_send_action_new(ChannelSend *send, ChannelSendActionType type, Port *port, StereoPorts *stereo, float amount, const PortConnectionsManager *port_connections_mgr, GError **error)
Creates a new action.
bool channel_send_action_perform(ChannelSend *send, ChannelSendActionType type, Port *port, StereoPorts *stereo, float amount, const PortConnectionsManager *port_connections_mgr, GError **error)
Wrapper to create action and perform it.
Port connections manager.
Action for channel send changes.
PortIdentifier * l_id
Target port identifiers.
PortConnectionsManager * connections_mgr_before
A clone of the port connections at the start of the action.
PortConnectionsManager * connections_mgr_after
A clone of the port connections after applying the action.
ChannelSendActionType type
Action type.
Channel send.
Port connections manager.
Struct used to identify Ports in the project.
Must ONLY be created via port_new()
Definition port.h:136
L & R port, for convenience.
Definition port.h:501
Base struct to be inherited by implementing undoable actions.
Undoable actions.