Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
channel.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2022 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
11#ifndef __AUDIO_CHANNEL_H__
12#define __AUDIO_CHANNEL_H__
13
14#include "zrythm-config.h"
15
16#include "dsp/channel_send.h"
17#include "dsp/ext_port.h"
18#include "dsp/fader.h"
19#include "plugins/plugin.h"
20#include "utils/audio.h"
21#include "utils/yaml.h"
22
23#include <gdk/gdk.h>
24
25typedef struct AutomationTrack AutomationTrack;
26typedef struct _ChannelWidget ChannelWidget;
27typedef struct Track Track;
28typedef struct _TrackWidget TrackWidget;
29typedef struct ExtPort ExtPort;
30
37#define CHANNEL_SCHEMA_VERSION 2
38
40#define CHANNEL_MAGIC 8431676
41#define IS_CHANNEL(x) (((Channel *) x)->magic == CHANNEL_MAGIC)
42#define IS_CHANNEL_AND_NONNULL(x) (x && IS_CHANNEL (x))
43
44#define FOREACH_STRIP for (int i = 0; i < STRIP_SIZE; i++)
45#define FOREACH_AUTOMATABLE(ch) for (int i = 0; i < ch->num_automatables; i++)
46#define MAX_FADER_AMP 1.42f
47
48#define channel_is_in_active_project(self) \
49 (self->track && track_is_in_active_project (self->track))
50
56typedef struct Channel
57{
58 int schema_version;
65
68
71
80
91 int num_ext_midi_ins;
92
96
107 int num_ext_stereo_l_ins;
108
111
122 int num_ext_stereo_r_ins;
123
126
133
137
140
147
153
154 /*
155 * Ports for direct (track-to-track) routing with the exception of master,
156 * which will route the output to monitor in.
157 */
158 StereoPorts * stereo_out;
159
166
168 unsigned int output_name_hash;
169
172
174 int width;
175
177 int magic;
178
181
184} Channel;
185
186NONNULL void
187channel_init_loaded (Channel * channel, Track * track);
188
199NONNULL void
201 Channel * self,
202 const long g_frames_start,
203 const nframes_t nframes);
204
209void
210channel_append_ports (Channel * self, GPtrArray * ports, bool include_plugins);
211
212NONNULL void
213channel_set_magic (Channel * self);
214
218NONNULL void
220
226void
228
229NONNULL void
230channel_set_phase (void * channel, float phase);
231
232NONNULL float
233channel_get_phase (void * channel);
234
235NONNULL void
236channel_set_balance_control (void * _channel, float pan);
237
241NONNULL void
242channel_add_balance_control (void * _channel, float pan);
243
244NONNULL float
245channel_get_balance_control (void * _channel);
246
250NONNULL void
251channel_reset_fader (Channel * self, bool fire_events);
252
263void
265 Channel * self,
266 const Plugin * pl,
267 const MixerSelections * sel,
268 const PluginDescriptor * descr,
269 int slot,
270 ZPluginSlotType slot_type,
271 bool copy,
272 bool ask_if_overwrite);
273
280NONNULL void
282
287NONNULL Channel *
289
298NONNULL void
300
323NONNULL bool
325 Channel * channel,
326 ZPluginSlotType slot_type,
327 int pos,
328 Plugin * plugin,
329 bool confirm,
330 bool moving_plugin,
331 bool gen_automatables,
332 bool recalc_graph,
333 bool pub_events);
334
335NONNULL Track *
336channel_get_track (Channel * self);
337
338NONNULL Track *
339channel_get_output_track (Channel * self);
340
345NONNULL void
347
352NONNULL AutomationTrack *
354 Channel * channel,
355 PortIdentifier::Flags port_flags);
356
373NONNULL void
375 Channel * channel,
376 ZPluginSlotType slot_type,
377 int slot,
378 bool moving_plugin,
379 bool deleting_plugin,
380 bool deleting_channel,
381 bool recalc_graph);
382
387NONNULL void
389 Channel * self,
390 unsigned int old_name_hash,
391 unsigned int new_name_hash);
392
393NONNULL int
394channel_get_plugins (Channel * self, Plugin ** pls);
395
399NONNULL bool
401
405NONNULL void
406channel_set_mono_compat_enabled (Channel * self, bool enabled, bool fire_events);
407
411NONNULL bool
413
417NONNULL void
418channel_set_swap_phase (Channel * self, bool enabled, bool fire_events);
419
423Plugin *
424channel_get_plugin_at (const Channel * self, int slot, ZPluginSlotType slot_type);
425
430void
431channel_select_all (Channel * self, ZPluginSlotType type, bool select);
432
436NONNULL void
438
450NONNULL_ARGS (1, 2)
451Channel * channel_clone (Channel * ch, Track * track, GError ** error);
452
466NONNULL void
467channel_disconnect (Channel * channel, bool remove_pl);
468
476NONNULL void
478
483#endif
Audio utils.
Channel send.
Backend for faders or other volume/gain controls.
External ports.
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
void channel_select_all(Channel *self, ZPluginSlotType type, bool select)
Selects/deselects all plugins in the given slot type.
void channel_handle_plugin_import(Channel *self, const Plugin *pl, const MixerSelections *sel, const PluginDescriptor *descr, int slot, ZPluginSlotType slot_type, bool copy, bool ask_if_overwrite)
Handles import (paste/drop) of plugins or plugin descriptors or mixer selections.
NONNULL void channel_remove_plugin(Channel *channel, ZPluginSlotType slot_type, int slot, bool moving_plugin, bool deleting_plugin, bool deleting_channel, bool recalc_graph)
Removes a plugin at pos from the channel.
NONNULL void channel_add_balance_control(void *_channel, float pan)
Adds to (or subtracts from) the pan.
Channel * channel_clone(Channel *ch, Track *track, GError **error)
Clones the channel recursively.
#define EXT_PORTS_MAX
Maximum external ports.
Definition ext_port.h:47
NONNULL void channel_disconnect(Channel *channel, bool remove_pl)
Disconnects the channel from the processing chain.
NONNULL bool channel_add_plugin(Channel *channel, ZPluginSlotType slot_type, int pos, Plugin *plugin, bool confirm, bool moving_plugin, bool gen_automatables, bool recalc_graph, bool pub_events)
Adds given plugin to given position in the strip.
NONNULL void channel_free(Channel *channel)
Frees the channel.
NONNULL bool channel_get_mono_compat_enabled(Channel *self)
Gets whether mono compatibility is enabled.
void channel_append_ports(Channel *self, GPtrArray *ports, bool include_plugins)
Appends all channel ports and optionally plugin ports to the array.
NONNULL void channel_set_caches(Channel *self)
Sets caches for processing.
NONNULL void channel_set_mono_compat_enabled(Channel *self, bool enabled, bool fire_events)
Sets whether mono compatibility is enabled.
NONNULL void channel_expose_ports_to_backend(Channel *ch)
Exposes the channel's ports to the backend.
NONNULL void channel_update_track_name_hash(Channel *self, unsigned int old_name_hash, unsigned int new_name_hash)
Updates the track name hash in the channel and all related ports and identifiers.
NONNULL bool channel_get_swap_phase(Channel *self)
Gets whether mono compatibility is enabled.
NONNULL Channel * channel_new(Track *track)
Creates a channel of the given type with the given label.
NONNULL void channel_reset_fader(Channel *self, bool fire_events)
Sets fader to 0.0.
NONNULL AutomationTrack * channel_get_automation_track(Channel *channel, PortIdentifier::Flags port_flags)
Convenience function to get the automation track of the given type for the channel.
NONNULL void channel_process(Channel *channel)
The process function prototype.
NONNULL void channel_prepare_process(Channel *channel)
Prepares the channel for processing.
NONNULL void channel_handle_recording(Channel *self, const long g_frames_start, const nframes_t nframes)
Handles the recording logic inside the process cycle.
void channel_connect(Channel *ch)
Connects the channel's ports.
NONNULL void channel_set_swap_phase(Channel *self, bool enabled, bool fire_events)
Sets whether mono compatibility is enabled.
NONNULL void channel_reconnect_ext_input_ports(Channel *ch)
Called when the input has changed for Midi, Instrument or Audio tracks.
ZPluginSlotType
uint32_t nframes_t
Frame count.
Definition types.h:39
#define STRIP_SIZE
Number of plugin slots per channel.
Definition audio.h:75
Base plugin.
Channel send.
A Channel is part of a Track (excluding Tracks that don't have Channels) and contains information rel...
Definition channel.h:57
Plugin * instrument
The instrument plugin, if instrument track.
Definition channel.h:70
ExtPort * ext_stereo_l_ins[EXT_PORTS_MAX]
External audio L inputs that are currently connected to this channel as official inputs,...
Definition channel.h:106
Fader * prefader
Prefader.
Definition channel.h:146
Plugin * midi_fx[STRIP_SIZE]
The MIDI effect strip on instrument/MIDI tracks.
Definition channel.h:64
int midi_channels[16]
1 or 0 flags for each channel to enable it or disable it.
Definition channel.h:132
Track * track
Pointer to owner track.
Definition channel.h:183
int has_output
Whether or not output_pos corresponds to a Track or not.
Definition channel.h:165
bool all_stereo_r_ins
If true, the channel will connect to all stereo R ins found.
Definition channel.h:125
Plugin * inserts[STRIP_SIZE]
The channel insert strip.
Definition channel.h:67
bool all_stereo_l_ins
If true, the channel will connect to all stereo L ins found.
Definition channel.h:110
ChannelSend * sends[STRIP_SIZE]
The sends strip.
Definition channel.h:79
ExtPort * ext_midi_ins[EXT_PORTS_MAX]
External MIDI inputs that are currently connected to this channel as official inputs,...
Definition channel.h:90
bool all_midi_channels
If true, the channel will accept MIDI messages from all MIDI channels.
Definition channel.h:136
Fader * fader
The channel fader.
Definition channel.h:139
bool all_midi_ins
If true, the channel will connect to all MIDI ins found.
Definition channel.h:95
unsigned int output_name_hash
Output track.
Definition channel.h:168
Port * midi_out
MIDI output for sending MIDI signals to other destinations, such as other channels when directly rout...
Definition channel.h:152
ChannelWidget * widget
The channel widget.
Definition channel.h:180
int track_pos
Track associated with this channel.
Definition channel.h:171
int magic
This must be set to CHANNEL_MAGIC.
Definition channel.h:177
ExtPort * ext_stereo_r_ins[EXT_PORTS_MAX]
External audio R inputs that are currently connected to this channel as official inputs,...
Definition channel.h:121
int width
Channel widget width - reserved for future use.
Definition channel.h:174
External port.
Definition ext_port.h:69
A Fader is a processor that is used for volume controls and pan.
Definition fader.h:91
Selections to be used for the timeline's current selections, copying, undoing, etc.
The base plugin Inheriting plugins must have this as a child.
Definition plugin.h:74
Must ONLY be created via port_new()
Definition port.h:136
L & R port, for convenience.
Definition port.h:501
The TrackWidget is split into 3 parts.
Definition track.h:107
Track to be inserted into the Project's Tracklist.
Definition track.h:177
YAML utils.