Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
automation_track.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
10#ifndef __AUDIO_AUTOMATION_TRACK_H__
11#define __AUDIO_AUTOMATION_TRACK_H__
12
13#include "zrythm-config.h"
14
16#include "dsp/port.h"
17#include "dsp/position.h"
18#include "dsp/region.h"
19
20typedef struct Port Port;
21typedef struct Track Track;
25
32#define MAX_AUTOMATION_POINTS 1200
33
35#define AUTOMATION_RECORDING_TOUCH_REL_MS 800
36
37enum class AutomationMode
38{
39 AUTOMATION_MODE_READ,
40 AUTOMATION_MODE_RECORD,
41 AUTOMATION_MODE_OFF,
42 NUM_AUTOMATION_MODES,
43};
44
45enum class AutomationRecordMode
46{
47 AUTOMATION_RECORD_MODE_TOUCH,
48 AUTOMATION_RECORD_MODE_LATCH,
49 NUM_AUTOMATION_RECORD_MODES,
50};
51
52typedef struct AutomationTrack
53{
55 int index;
56
59
61 bool created;
62
65 int num_regions;
66 size_t regions_size;
67
70 int num_region_snapshots;
71
80 bool visible;
81
83 int y;
84
86 double height;
87
91
93 AutomationMode automation_mode;
94
97 AutomationRecordMode record_mode;
98
102
105
114
123
126 int num_top_right_buttons;
127 CustomButtonWidget * top_left_buttons[8];
128 int num_top_left_buttons;
129 CustomButtonWidget * bot_right_buttons[8];
130 int num_bot_right_buttons;
131
134
135 CustomButtonWidget * bot_left_buttons[8];
136 int num_bot_left_buttons;
137
141
145
146COLD NONNULL_ARGS (1) void automation_track_init_loaded (
147 AutomationTrack * self,
148 AutomationTracklist * atl);
149
154NONNULL AutomationTrack *
156
157NONNULL bool
158automation_track_validate (AutomationTrack * self);
159
163void
164automation_mode_get_localized (AutomationMode mode, char * buf);
165
169void
170automation_record_mode_get_localized (AutomationRecordMode mode, char * buf);
171
180NONNULL AutomationTrack *
182
190HOT AutomationTrack *
191automation_track_find_from_port (Port * port, Track * track, bool basic_search);
192
193void
194automation_track_set_automation_mode (
195 AutomationTrack * self,
196 AutomationMode mode,
197 bool fire_events);
198
199NONNULL static inline void
200automation_track_swap_record_mode (AutomationTrack * self)
201{
202 self->record_mode = static_cast<AutomationRecordMode> (
203 (static_cast<int> (self->record_mode) + 1)
204 % static_cast<int> (AutomationRecordMode::NUM_AUTOMATION_RECORD_MODES));
205}
206
207NONNULL AutomationTracklist *
208automation_track_get_automation_tracklist (AutomationTrack * self);
209
218HOT NONNULL bool
220
237HOT NONNULL bool
239 const AutomationTrack * const at,
240 const gint64 cur_time,
241 const bool record_aps);
242
249NONNULL void
251
259NONNULL void
261
266// int
267// automation_track_get_visible_y_offset (
268// AutomationTrack * self);
269
278NONNULL void
280 AutomationTrack * self,
281 bool from_ticks,
282 bool bpm_change);
283
288NONNULL void
290
294NONNULL AutomationTrack *
296
297NONNULL Track *
298automation_track_get_track (AutomationTrack * self);
299
309NONNULL AutomationPoint *
311 const AutomationTrack * self,
312 const Position * pos,
313 bool ends_after,
314 bool use_snapshots);
315
325Region *
327 const AutomationTrack * self,
328 const Position * pos,
329 bool ends_after,
330 bool use_snapshots);
331
335NONNULL void
337
341NONNULL void
343
348NONNULL void
350
366NONNULL float
368 AutomationTrack * self,
369 Position * pos,
370 bool normalized,
371 bool ends_after,
372 bool use_snapshots);
373
378NONNULL int
380 AutomationTrack * self,
381 float normalized_val);
382
383#if 0
384NONNULL
385Port *
386automation_track_get_port (
387 const AutomationTrack * const self);
388#endif
389
393NONNULL Region *
395
396NONNULL void
397automation_track_set_caches (AutomationTrack * self, CacheTypes types);
398
399NONNULL bool
400automation_track_contains_automation (const AutomationTrack * self);
401
402NONNULL bool
403automation_track_verify (AutomationTrack * self);
404
408NONNULL void
410
411#endif // __AUDIO_AUTOMATION_TRACK_H__
Automation point API.
Ports that transfer audio/midi/other signals to one another.
A region in the timeline.
NONNULL void automation_track_remove_region(AutomationTrack *self, Region *region)
Removes a region from the automation track.
NONNULL void automation_track_add_region(AutomationTrack *self, Region *region)
Adds an automation Region to the AutomationTrack.
NONNULL Region * automation_track_get_last_region(AutomationTrack *self)
Gets the last Region in the AutomationTrack.
int y
Y local to track.
AutomationTracklist * atl
Pointer to owner automation tracklist, if any.
NONNULL AutomationTrack * automation_track_clone(AutomationTrack *src)
Clones the AutomationTrack.
NONNULL float automation_track_get_val_at_pos(AutomationTrack *self, Position *pos, bool normalized, bool ends_after, bool use_snapshots)
Returns the actual parameter value at the given position.
bool created
Whether it has been created by the user yet or not.
bool recording_paused
This must only be set by the RecordingManager when temporarily pausing recording, eg when looping or ...
HOT AutomationTrack * automation_track_find_from_port(Port *port, Track *track, bool basic_search)
Finds the AutomationTrack associated with port.
NONNULL int automation_track_get_y_px_from_normalized_val(AutomationTrack *self, float normalized_val)
Returns the y pixels from the value based on the allocation of the automation track.
AutomationRecordMode record_mode
Automation record mode, when AutomationTrack::automation_mode is set to record.
AutomationModeWidget * am_widget
Automation mode button group.
int index
Index in parent AutomationTracklist.
NONNULL void automation_track_set_index(AutomationTrack *self, int index)
Sets the index of the AutomationTrack in the AutomationTracklist.
Port * port
Cache used during DSP.
bool recording_start_sent
This is a flag to let the recording manager know that a START signal was already sent for recording.
NONNULL AutomationTrack * automation_track_new(Port *port)
Creates an automation track for the given Port.
NONNULL void automation_track_insert_region(AutomationTrack *self, Region *region, int idx)
Inserts an automation Region to the AutomationTrack at the given index.
NONNULL void automation_track_clear(AutomationTrack *self)
Removes and frees all arranger objects recursively.
double height
Position of multipane handle.
NONNULL void automation_track_free(AutomationTrack *at)
Frees the automation track.
NONNULL void automation_track_update_positions(AutomationTrack *self, bool from_ticks, bool bpm_change)
Returns the visible y offset from the top of the track widget.
void automation_record_mode_get_localized(AutomationRecordMode mode, char *buf)
Gets the automation mode as a localized string.
Region ** regions
The automation Region's.
NONNULL AutomationTrack * automation_track_find_from_port_id(PortIdentifier *id, bool basic_search)
NONNULL void automation_track_unselect_all(AutomationTrack *self)
Unselects all arranger objects.
HOT NONNULL bool automation_track_should_be_recording(const AutomationTrack *const at, const gint64 cur_time, const bool record_aps)
Returns if the automation track should currently be recording data.
CustomButtonWidget * top_right_buttons[8]
Buttons used by the track widget.
AutomationMode automation_mode
Automation mode.
PortIdentifier port_id
Identifier of the Port this AutomationTrack is for.
void automation_mode_get_localized(AutomationMode mode, char *buf)
Gets the automation mode as a localized string.
NONNULL AutomationPoint * automation_track_get_ap_before_pos(const AutomationTrack *self, const Position *pos, bool ends_after, bool use_snapshots)
Returns the automation point before the Position on the timeline.
Region ** region_snapshots
Snapshots used during playback TODO unimplemented.
bool recording_started
To be set to true when recording starts (when the first change is received) and false when recording ...
Region * recording_region
Region currently recording to.
Region * automation_track_get_region_before_pos(const AutomationTrack *self, const Position *pos, bool ends_after, bool use_snapshots)
Returns the Region that starts before given Position, if any.
COLD NONNULL_ARGS(1) void automation_track_init_loaded(AutomationTrack *self
Inits a loaded AutomationTracklist.
float last_recorded_value
Last value recorded in this automation track.
HOT NONNULL bool automation_track_should_read_automation(AutomationTrack *at, gint64 cur_time)
Returns whether the automation in the automation track should be read.
bool visible
Whether visible or not.
Position struct and API.
Custom button group to be drawn inside drawing areas.
An automation point inside an AutomationTrack.
Each track has an automation tracklist with automation tracks to be generated at runtime,...
Custom button to be drawn inside drawing areas.
Struct used to identify Ports in the project.
Must ONLY be created via port_new()
Definition port.h:136
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:124
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:72
Track to be inserted into the Project's Tracklist.
Definition track.h:177