Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
track_processor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_TRACK_PROCESSOR_H__
11#define __AUDIO_TRACK_PROCESSOR_H__
12
13#include "dsp/port.h"
14#include "utils/midi.h"
15#include "utils/types.h"
16#include "utils/yaml.h"
17
18typedef struct StereoPorts StereoPorts;
19typedef struct Port Port;
20typedef struct Track Track;
21typedef struct MidiMappings MidiMappings;
23TYPEDEF_STRUCT (MPMCQueue);
24
31#define TRACK_PROCESSOR_SCHEMA_VERSION 1
32
33#define TRACK_PROCESSOR_MAGIC 81213128
34#define IS_TRACK_PROCESSOR(tr) ((tr) && (tr)->magic == TRACK_PROCESSOR_MAGIC)
35
36#define track_processor_is_in_active_project(self) \
37 (self->track && track_is_in_active_project (self->track))
38
43typedef struct TrackProcessor
44{
45 int schema_version;
46
51
54
57
65
70
80
85
94
105
106 /* --- MIDI controls --- */
107
110
112 Port * midi_cc[128 * 16];
113
116
127
135
136 /* --- end MIDI controls --- */
137
144 float r_port_db;
145
148
156
164
165 int magic;
167
168static const cyaml_schema_field_t track_processor_fields_schema[] = {
169 YAML_FIELD_INT (TrackProcessor, schema_version),
170 YAML_FIELD_MAPPING_PTR_OPTIONAL (TrackProcessor, mono, port_fields_schema),
171 YAML_FIELD_MAPPING_PTR_OPTIONAL (TrackProcessor, input_gain, port_fields_schema),
172 YAML_FIELD_MAPPING_PTR_OPTIONAL (TrackProcessor, output_gain, port_fields_schema),
173 YAML_FIELD_MAPPING_PTR_OPTIONAL (TrackProcessor, midi_in, port_fields_schema),
174 YAML_FIELD_MAPPING_PTR_OPTIONAL (TrackProcessor, midi_out, port_fields_schema),
175 YAML_FIELD_MAPPING_PTR_OPTIONAL (TrackProcessor, piano_roll, port_fields_schema),
178 monitor_audio,
179 port_fields_schema),
182 stereo_in,
183 stereo_ports_fields_schema),
186 stereo_out,
187 stereo_ports_fields_schema),
188 YAML_FIELD_FIXED_SIZE_PTR_ARRAY (TrackProcessor, midi_cc, port_schema, 128 * 16),
189 YAML_FIELD_FIXED_SIZE_PTR_ARRAY (TrackProcessor, pitch_bend, port_schema, 16),
192 poly_key_pressure,
193 port_schema,
194 16),
197 channel_pressure,
198 port_schema,
199 16),
200
201 CYAML_FIELD_END
202};
203
204static const cyaml_schema_value_t track_processor_schema = {
205 YAML_VALUE_PTR (TrackProcessor, track_processor_fields_schema),
206};
207
211COLD NONNULL_ARGS (
212 1) void track_processor_init_loaded (TrackProcessor * self, Track * track);
213
214#if 0
215void
216track_processor_set_is_project (
217 TrackProcessor * self,
218 bool is_project);
219#endif
220
225COLD WARN_UNUSED_RESULT TrackProcessor *
227
231void
233
237void
239
244void
246
247static inline Track *
248track_processor_get_track (const TrackProcessor * self)
249{
250#if 0
251 g_return_val_if_fail (
252 IS_TRACK_PROCESSOR (self) && IS_TRACK (self->track), NULL);
253#endif
254 g_return_val_if_fail (self->track, NULL);
255
256 return self->track;
257}
258
276void
278 TrackProcessor * self,
279 const EngineProcessTimeInfo * const time_nfo);
280
287void
289
296void
298
303void
305
310void
312
313#if 0
314void
315track_processor_update_track_name_hash (
316 TrackProcessor * self);
317#endif
318
319void
320track_processor_append_ports (TrackProcessor * self, GPtrArray * ports);
321
325void
327
332#endif
Ports that transfer audio/midi/other signals to one another.
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
void track_processor_copy_values(TrackProcessor *dest, TrackProcessor *src)
Copy port values from src to dest.
void track_processor_connect_to_plugin(TrackProcessor *self, Plugin *pl)
Connect the TrackProcessor's out ports to the Plugin's input ports.
void track_processor_clear_buffers(TrackProcessor *self)
Clears all buffers.
void track_processor_free(TrackProcessor *self)
Frees the TrackProcessor.
COLD WARN_UNUSED_RESULT TrackProcessor * track_processor_new(Track *track)
Creates a new track processor for the given track.
void track_processor_connect_to_prefader(TrackProcessor *self)
Connects the TrackProcessor's stereo out ports to the Channel's prefader in ports.
void track_processor_disconnect_all(TrackProcessor *self)
Disconnects all ports connected to the TrackProcessor.
void track_processor_disconnect_from_prefader(TrackProcessor *self)
Disconnect the TrackProcessor's stereo out ports from the prefader.
void track_processor_process(TrackProcessor *self, const EngineProcessTimeInfo *const time_nfo)
Process the TrackProcessor.
void track_processor_disconnect_from_plugin(TrackProcessor *self, Plugin *pl)
Disconnect the TrackProcessor's out ports from the Plugin's input ports.
#define YAML_FIELD_FIXED_SIZE_PTR_ARRAY(owner, member, schema, size)
Fixed-width array of pointers with fixed count.
Definition yaml.h:67
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:202
#define YAML_FIELD_MAPPING_PTR_OPTIONAL(owner, member, schema)
Mapping pointer to a struct.
Definition yaml.h:43
MIDI utils.
Common struct to pass around during processing to avoid repeating the data in function arguments.
Definition types.h:138
Multiple Producer Multiple Consumer lock-free queue.
Definition mpmc_queue.h:69
All MIDI mappings in Zrythm.
The base plugin Inheriting plugins must have this as a child.
Definition plugin.h:71
Must ONLY be created via port_new()
Definition port.h:140
L & R port, for convenience.
Definition port.h:562
A TrackProcessor is a processor that is used as the first entry point when processing a track.
Port * monitor_audio
Whether to monitor the audio output.
MPMCQueue * updated_midi_automatable_ports
A queue of MIDI CC ports whose values have been recently updated.
Port * output_gain
Output gain, if audio.
Port * midi_in
MIDI in Port.
Port * poly_key_pressure[16]
Polyphonic key pressure (aftertouch).
Port * channel_pressure[16]
Channel pressure (aftertouch).
StereoPorts * stereo_in
L & R audio input ports, if audio.
Port * midi_cc[128 *16]
MIDI CC control ports, 16 channels.
bool pending_midi_panic
To be set to true when a panic (all notes off) message should be sent during processing.
MidiMappings * cc_mappings
Mappings to each CC port.
Port * input_gain
Input gain, if audio.
StereoPorts * stereo_out
L & R audio output ports, if audio.
Port * pitch_bend[16]
Pitch bend.
Track * track
Pointer to owner track, if any.
Port * midi_out
MIDI out port, if MIDI.
float l_port_db
Current dBFS after processing each output port.
Port * piano_roll
MIDI input for receiving MIDI signals from the piano roll (i.e., MIDI notes inside regions) or other ...
Port * mono
Mono toggle, if audio.
Track to be inserted into the Project's Tracklist.
Definition track.h:186
Custom types.
YAML utils.