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
17typedef enum 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} ChannelSendActionType;
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, CHANNEL_SEND_ACTION_DISCONNECT, NULL, NULL, 0.f, \
80 PORT_CONNECTIONS_MGR, error)
81
82#define channel_send_action_new_connect_midi(send, midi, error) \
83 channel_send_action_new ( \
84 send, CHANNEL_SEND_ACTION_CONNECT_MIDI, midi, NULL, 0.f, \
85 PORT_CONNECTIONS_MGR, error)
86
87#define channel_send_action_new_connect_audio(send, stereo, error) \
88 channel_send_action_new ( \
89 send, CHANNEL_SEND_ACTION_CONNECT_STEREO, NULL, stereo, 0.f, \
90 PORT_CONNECTIONS_MGR, error)
91
92#define channel_send_action_new_connect_sidechain(send, stereo, error) \
93 channel_send_action_new ( \
94 send, CHANNEL_SEND_ACTION_CONNECT_SIDECHAIN, NULL, stereo, 0.f, \
95 PORT_CONNECTIONS_MGR, error)
96
97#define channel_send_action_new_change_amount(send, amt, error) \
98 channel_send_action_new ( \
99 send, CHANNEL_SEND_ACTION_CHANGE_AMOUNT, NULL, NULL, amt, NULL, error)
100
101NONNULL ChannelSendAction *
102channel_send_action_clone (const ChannelSendAction * src);
103
110bool
112 ChannelSend * send,
113 ChannelSendActionType type,
114 Port * port,
115 StereoPorts * stereo,
116 float amount,
117 const PortConnectionsManager * port_connections_mgr,
118 GError ** error);
119
120#define channel_send_action_perform_disconnect(send, error) \
121 channel_send_action_perform ( \
122 send, CHANNEL_SEND_ACTION_DISCONNECT, NULL, NULL, 0.f, \
123 PORT_CONNECTIONS_MGR, error)
124
125#define channel_send_action_perform_connect_midi(send, midi, error) \
126 channel_send_action_perform ( \
127 send, CHANNEL_SEND_ACTION_CONNECT_MIDI, midi, NULL, 0.f, \
128 PORT_CONNECTIONS_MGR, error)
129
130#define channel_send_action_perform_connect_audio(send, stereo, error) \
131 channel_send_action_perform ( \
132 send, CHANNEL_SEND_ACTION_CONNECT_STEREO, NULL, stereo, 0.f, \
133 PORT_CONNECTIONS_MGR, error)
134
135#define channel_send_action_perform_connect_sidechain(send, stereo, error) \
136 channel_send_action_perform ( \
137 send, CHANNEL_SEND_ACTION_CONNECT_SIDECHAIN, NULL, stereo, 0.f, \
138 PORT_CONNECTIONS_MGR, error)
139
140#define channel_send_action_perform_change_amount(send, amt, error) \
141 channel_send_action_perform ( \
142 send, CHANNEL_SEND_ACTION_CHANGE_AMOUNT, NULL, NULL, amt, NULL, error)
143
144int
145channel_send_action_do (ChannelSendAction * self, GError ** error);
146
147int
148channel_send_action_undo (ChannelSendAction * self, GError ** error);
149
150char *
151channel_send_action_stringize (ChannelSendAction * self);
152
153void
154channel_send_action_free (ChannelSendAction * self);
155
160#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:139
L & R port, for convenience.
Definition port.h:505
Base struct to be inherited by implementing undoable actions.
Undoable actions.