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
25#ifdef HAVE_JACK
26# include "weak_libjack.h"
27#endif
28
29typedef struct AutomationTrack AutomationTrack;
30typedef struct _ChannelWidget ChannelWidget;
31typedef struct Track Track;
32typedef struct _TrackWidget TrackWidget;
33typedef struct ExtPort ExtPort;
34
41#define CHANNEL_SCHEMA_VERSION 2
42
44#define CHANNEL_MAGIC 8431676
45#define IS_CHANNEL(x) (((Channel *) x)->magic == CHANNEL_MAGIC)
46#define IS_CHANNEL_AND_NONNULL(x) (x && IS_CHANNEL (x))
47
48#define FOREACH_STRIP for (int i = 0; i < STRIP_SIZE; i++)
49#define FOREACH_AUTOMATABLE(ch) for (int i = 0; i < ch->num_automatables; i++)
50#define MAX_FADER_AMP 1.42f
51
52#define channel_is_in_active_project(self) \
53 (self->track && track_is_in_active_project (self->track))
54
60typedef struct Channel
61{
62 int schema_version;
69
72
75
84
95 int num_ext_midi_ins;
96
100
111 int num_ext_stereo_l_ins;
112
115
126 int num_ext_stereo_r_ins;
127
130
137
141
144
151
157
158 /*
159 * Ports for direct (track-to-track) routing with the exception of master,
160 * which will route the output to monitor in.
161 */
162 StereoPorts * stereo_out;
163
170
172 unsigned int output_name_hash;
173
176
178 int width;
179
181 int magic;
182
185
188} Channel;
189
190NONNULL void
191channel_init_loaded (Channel * channel, Track * track);
192
203NONNULL void
205 Channel * self,
206 const long g_frames_start,
207 const nframes_t nframes);
208
213void
214channel_append_ports (Channel * self, GPtrArray * ports, bool include_plugins);
215
216NONNULL void
217channel_set_magic (Channel * self);
218
222NONNULL void
224
230void
232
233NONNULL void
234channel_set_phase (void * channel, float phase);
235
236NONNULL float
237channel_get_phase (void * channel);
238
239NONNULL void
240channel_set_balance_control (void * _channel, float pan);
241
245NONNULL void
246channel_add_balance_control (void * _channel, float pan);
247
248NONNULL float
249channel_get_balance_control (void * _channel);
250
254NONNULL void
255channel_reset_fader (Channel * self, bool fire_events);
256
267void
269 Channel * self,
270 const Plugin * pl,
271 const MixerSelections * sel,
272 const PluginDescriptor * descr,
273 int slot,
274 ZPluginSlotType slot_type,
275 bool copy,
276 bool ask_if_overwrite);
277
284NONNULL void
286
291NONNULL Channel *
293
302NONNULL void
304
327NONNULL bool
329 Channel * channel,
330 ZPluginSlotType slot_type,
331 int pos,
332 Plugin * plugin,
333 bool confirm,
334 bool moving_plugin,
335 bool gen_automatables,
336 bool recalc_graph,
337 bool pub_events);
338
339NONNULL Track *
340channel_get_track (Channel * self);
341
342NONNULL Track *
343channel_get_output_track (Channel * self);
344
349NONNULL void
351
356NONNULL AutomationTrack *
358
375NONNULL void
377 Channel * channel,
378 ZPluginSlotType slot_type,
379 int slot,
380 bool moving_plugin,
381 bool deleting_plugin,
382 bool deleting_channel,
383 bool recalc_graph);
384
389NONNULL void
391 Channel * self,
392 unsigned int old_name_hash,
393 unsigned int new_name_hash);
394
395NONNULL int
396channel_get_plugins (Channel * self, Plugin ** pls);
397
401NONNULL bool
403
407NONNULL void
408channel_set_mono_compat_enabled (Channel * self, bool enabled, bool fire_events);
409
413NONNULL bool
415
419NONNULL void
420channel_set_swap_phase (Channel * self, bool enabled, bool fire_events);
421
425Plugin *
426channel_get_plugin_at (const Channel * self, int slot, ZPluginSlotType slot_type);
427
432void
433channel_select_all (Channel * self, ZPluginSlotType type, bool select);
434
438NONNULL void
440
452NONNULL_ARGS (1, 2)
453Channel * channel_clone (Channel * ch, Track * track, GError ** error);
454
468NONNULL void
469channel_disconnect (Channel * channel, bool remove_pl);
470
478NONNULL void
480
485#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.
NONNULL AutomationTrack * channel_get_automation_track(Channel *channel, ZPortFlags port_flags)
Convenience function to get the automation track of the given type for the channel.
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.
ZPortFlags
Port flags.
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 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:35
#define STRIP_SIZE
Number of plugin slots per channel.
Definition audio.h:76
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:61
Plugin * instrument
The instrument plugin, if instrument track.
Definition channel.h:74
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:110
Fader * prefader
Prefader.
Definition channel.h:150
Plugin * midi_fx[STRIP_SIZE]
The MIDI effect strip on instrument/MIDI tracks.
Definition channel.h:68
int midi_channels[16]
1 or 0 flags for each channel to enable it or disable it.
Definition channel.h:136
Track * track
Pointer to owner track.
Definition channel.h:187
int has_output
Whether or not output_pos corresponds to a Track or not.
Definition channel.h:169
bool all_stereo_r_ins
If true, the channel will connect to all stereo R ins found.
Definition channel.h:129
Plugin * inserts[STRIP_SIZE]
The channel insert strip.
Definition channel.h:71
bool all_stereo_l_ins
If true, the channel will connect to all stereo L ins found.
Definition channel.h:114
ChannelSend * sends[STRIP_SIZE]
The sends strip.
Definition channel.h:83
ExtPort * ext_midi_ins[EXT_PORTS_MAX]
External MIDI inputs that are currently connected to this channel as official inputs,...
Definition channel.h:94
bool all_midi_channels
If true, the channel will accept MIDI messages from all MIDI channels.
Definition channel.h:140
Fader * fader
The channel fader.
Definition channel.h:143
bool all_midi_ins
If true, the channel will connect to all MIDI ins found.
Definition channel.h:99
unsigned int output_name_hash
Output track.
Definition channel.h:172
Port * midi_out
MIDI output for sending MIDI signals to other destinations, such as other channels when directly rout...
Definition channel.h:156
ChannelWidget * widget
The channel widget.
Definition channel.h:184
int track_pos
Track associated with this channel.
Definition channel.h:175
int magic
This must be set to CHANNEL_MAGIC.
Definition channel.h:181
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:125
int width
Channel widget width - reserved for future use.
Definition channel.h:178
External port.
Definition ext_port.h:69
A Fader is a processor that is used for volume controls and pan.
Definition fader.h:102
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:139
L & R port, for convenience.
Definition port.h:505
The TrackWidget is split into 3 parts.
Definition track.h:109
Track to be inserted into the Project's Tracklist.
Definition track.h:177
YAML utils.