Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
channel_send.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2020-2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_CHANNEL_SEND_H__
11#define __AUDIO_CHANNEL_SEND_H__
12
13#include <stdbool.h>
14
15#include "dsp/port.h"
16#include "dsp/port_identifier.h"
17#include "utils/yaml.h"
18
19typedef struct StereoPorts StereoPorts;
20typedef struct Track Track;
21typedef struct Port Port;
22typedef struct _ChannelSendWidget ChannelSendWidget;
24
31#define CHANNEL_SEND_SCHEMA_VERSION 1
32
37#define CHANNEL_SEND_POST_FADER_START_SLOT 6
38
39#define channel_send_is_prefader(x) \
40 (x->slot < CHANNEL_SEND_POST_FADER_START_SLOT)
41
42#define channel_send_is_in_active_project(self) \
43 (self->track && track_is_in_active_project (self->track))
44
59
63typedef struct ChannelSendTarget
64{
66
67 int track_pos;
68
69 PluginIdentifier pl_id;
70
71 char * port_group;
73
78char *
80
81char *
82channel_send_target_get_icon (const ChannelSendTarget * self);
83
84void
85channel_send_target_free (ChannelSendTarget * self);
86
93typedef struct ChannelSend
94{
95 int schema_version;
96
98 int slot;
99
106
113
120
127
131
139
142
145
147 unsigned int track_name_hash;
148
150
151static const cyaml_schema_field_t channel_send_fields_schema[] = {
152 YAML_FIELD_INT (ChannelSend, schema_version),
153 YAML_FIELD_INT (ChannelSend, slot),
154 YAML_FIELD_MAPPING_PTR (ChannelSend, amount, port_fields_schema),
155 YAML_FIELD_MAPPING_PTR (ChannelSend, enabled, port_fields_schema),
156 YAML_FIELD_INT (ChannelSend, is_sidechain),
157 YAML_FIELD_MAPPING_PTR_OPTIONAL (ChannelSend, midi_in, port_fields_schema),
160 stereo_in,
161 stereo_ports_fields_schema),
162 YAML_FIELD_MAPPING_PTR_OPTIONAL (ChannelSend, midi_out, port_fields_schema),
165 stereo_out,
166 stereo_ports_fields_schema),
167 YAML_FIELD_UINT (ChannelSend, track_name_hash),
168
169 CYAML_FIELD_END
170};
171
172static const cyaml_schema_value_t channel_send_schema = {
173 YAML_VALUE_PTR_NULLABLE (ChannelSend, channel_send_fields_schema),
174};
175
176NONNULL_ARGS (1)
177void channel_send_init_loaded (ChannelSend * self, Track * track);
178
183channel_send_new (unsigned int track_name_hash, int slot, Track * track);
184
188NONNULL Track *
190
191NONNULL bool
192channel_send_is_enabled (const ChannelSend * self);
193
194#define channel_send_is_empty(x) (!channel_send_is_enabled (x))
195
200NONNULL bool
202
209Track *
211
217NONNULL StereoPorts *
219
223NONNULL float
225
229NONNULL void
231
238bool
240 ChannelSend * self,
241 StereoPorts * stereo,
242 Port * l,
243 Port * r,
244 bool sidechain,
245 bool recalc_graph,
246 bool validate,
247 GError ** error);
248
252NONNULL bool
254 ChannelSend * self,
255 Port * port,
256 bool recalc_graph,
257 bool validate,
258 GError ** error);
259
263NONNULL void
264channel_send_disconnect (ChannelSend * self, bool recalc_graph);
265
266NONNULL void
267channel_send_set_amount (ChannelSend * self, float amount);
268
273NONNULL void
275
276NONNULL void
277channel_send_copy_values (ChannelSend * dest, const ChannelSend * src);
278
279NONNULL ChannelSend *
280channel_send_clone (const ChannelSend * src);
281
282NONNULL ChannelSendWidget *
283channel_send_find_widget (ChannelSend * self);
284
291void
293
294void
295channel_send_append_ports (ChannelSend * self, GPtrArray * ports);
296
302int
304 const ChannelSend * self,
305 const PortConnectionsManager * mgr,
306 GPtrArray * arr);
307
308void
309channel_send_prepare_process (ChannelSend * self);
310
311void
312channel_send_process (
313 ChannelSend * self,
314 const nframes_t local_offset,
315 const nframes_t nframes);
316
321bool
323 const ChannelSend * self,
324 const StereoPorts * stereo,
325 const Port * midi);
326
330NONNULL ChannelSend *
332
333NONNULL bool
334channel_send_validate (ChannelSend * self);
335
336NONNULL void
337channel_send_free (ChannelSend * self);
338
343#endif
Ports that transfer audio/midi/other signals to one another.
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
NONNULL Track * channel_send_get_track(const ChannelSend *self)
Gets the owner track.
NONNULL void channel_send_get_dest_name(ChannelSend *self, char *buf)
Get the name of the destination, or a placeholder text if empty.
Track * channel_send_get_target_track(ChannelSend *self, Track *owner)
Gets the target track.
NONNULL void channel_send_set_amount_from_widget(ChannelSend *self, float val)
Sets the amount from a widget amount (0.0-1.0).
bool channel_send_connect_stereo(ChannelSend *self, StereoPorts *stereo, Port *l, Port *r, bool sidechain, bool recalc_graph, bool validate, GError **error)
Connects a send to stereo ports.
int channel_send_append_connection(const ChannelSend *self, const PortConnectionsManager *mgr, GPtrArray *arr)
Appends the connection(s), if non-empty, to the given array (if not NULL) and returns the number of c...
bool channel_send_is_connected_to(const ChannelSend *self, const StereoPorts *stereo, const Port *midi)
Returns whether the send is connected to the given ports.
NONNULL bool channel_send_connect_midi(ChannelSend *self, Port *port, bool recalc_graph, bool validate, GError **error)
Connects a send to a midi port.
void channel_send_connect_to_owner(ChannelSend *self)
Connects the ports to the owner track if not connected.
ChannelSendTargetType
Target type.
ChannelSend * channel_send_new(unsigned int track_name_hash, int slot, Track *track)
Creates a channel send instance.
NONNULL ChannelSend * channel_send_find(ChannelSend *self)
Finds the project send from a given send instance.
NONNULL float channel_send_get_amount_for_widgets(ChannelSend *self)
Gets the amount to be used in widgets (0.0-1.0).
NONNULL void channel_send_disconnect(ChannelSend *self, bool recalc_graph)
Removes the connection at the given send.
NONNULL StereoPorts * channel_send_get_target_sidechain(ChannelSend *self)
Gets the target sidechain port.
NONNULL bool channel_send_is_target_sidechain(ChannelSend *self)
Returns whether the channel send target is a sidechain port (rather than a target track).
char * channel_send_target_describe(const ChannelSendTarget *self)
Returns a string describing self (track/plugin name/etc.).
@ CHANNEL_SEND_TARGET_TYPE_NONE
Remove send.
@ CHANNEL_SEND_TARGET_TYPE_TRACK
Send to track inputs.
@ CHANNEL_SEND_TARGET_TYPE_PLUGIN_SIDECHAIN
Send to plugin sidechain inputs.
uint32_t nframes_t
Frame count.
Definition types.h:35
#define YAML_FIELD_MAPPING_PTR(owner, member, schema)
Mapping pointer to a struct.
Definition yaml.h:37
#define YAML_VALUE_PTR_NULLABLE(cc, fields_schema)
Schema to be used as a pointer that can be NULL.
Definition yaml.h:209
#define YAML_FIELD_MAPPING_PTR_OPTIONAL(owner, member, schema)
Mapping pointer to a struct.
Definition yaml.h:43
Port identifier.
Send target (used in list views).
Channel send.
unsigned int track_name_hash
Track name hash (used in actions).
int slot
Slot index in the channel sends.
StereoPorts * stereo_in
Stereo input if audio send.
bool is_sidechain
If the send is a sidechain.
StereoPorts * stereo_out
Stereo output if audio send.
Port * enabled
Whether the send is currently enabled.
Port * midi_out
MIDI output if MIDI send.
Port * amount
Send amount (amplitude), 0 to 2 for audio, velocity multiplier for MIDI.
Port * midi_in
MIDI input if MIDI send.
Track * track
Pointer back to owner track.
Plugin identifier.
Port connections manager.
Must ONLY be created via port_new()
Definition port.h:138
L & R port, for convenience.
Definition port.h:522
Track to be inserted into the Project's Tracklist.
Definition track.h:186
YAML utils.