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
15#include <stdbool.h>
16
18#include "dsp/port.h"
19#include "dsp/position.h"
20#include "dsp/region.h"
21
22typedef struct Port Port;
23typedef struct _AutomationTrackWidget AutomationTrackWidget;
24typedef struct Track Track;
28
35#define MAX_AUTOMATION_POINTS 1200
36
38#define AUTOMATION_RECORDING_TOUCH_REL_MS 800
39
40typedef enum AutomationMode
41{
42 AUTOMATION_MODE_READ,
43 AUTOMATION_MODE_RECORD,
44 AUTOMATION_MODE_OFF,
45 NUM_AUTOMATION_MODES,
46} AutomationMode;
47
48typedef enum AutomationRecordMode
49{
50 AUTOMATION_RECORD_MODE_TOUCH,
51 AUTOMATION_RECORD_MODE_LATCH,
52 NUM_AUTOMATION_RECORD_MODES,
53} AutomationRecordMode;
54
55typedef struct AutomationTrack
56{
58 int index;
59
62
64 bool created;
65
68 int num_regions;
69 size_t regions_size;
70
73 int num_region_snapshots;
74
83 bool visible;
84
86 int y;
87
89 double height;
90
94
96 AutomationMode automation_mode;
97
100 AutomationRecordMode record_mode;
101
105
108
117
126
129 int num_top_right_buttons;
130 CustomButtonWidget * top_left_buttons[8];
131 int num_top_left_buttons;
132 CustomButtonWidget * bot_right_buttons[8];
133 int num_bot_right_buttons;
134
137
138 CustomButtonWidget * bot_left_buttons[8];
139 int num_bot_left_buttons;
140
144
148
149COLD NONNULL_ARGS (1) void automation_track_init_loaded (
150 AutomationTrack * self,
151 AutomationTracklist * atl);
152
157NONNULL AutomationTrack *
159
160NONNULL bool
161automation_track_validate (AutomationTrack * self);
162
166void
167automation_mode_get_localized (AutomationMode mode, char * buf);
168
172void
173automation_record_mode_get_localized (AutomationRecordMode mode, char * buf);
174
183NONNULL AutomationTrack *
185
193HOT AutomationTrack *
194automation_track_find_from_port (Port * port, Track * track, bool basic_search);
195
196void
197automation_track_set_automation_mode (
198 AutomationTrack * self,
199 AutomationMode mode,
200 bool fire_events);
201
202NONNULL static inline void
203automation_track_swap_record_mode (AutomationTrack * self)
204{
205 self->record_mode = (self->record_mode + 1) % NUM_AUTOMATION_RECORD_MODES;
206}
207
208NONNULL AutomationTracklist *
209automation_track_get_automation_tracklist (AutomationTrack * self);
210
219HOT NONNULL bool
221
238HOT NONNULL bool
240 const AutomationTrack * const at,
241 const gint64 cur_time,
242 const bool record_aps);
243
250NONNULL void
252
260NONNULL void
262
267// int
268// automation_track_get_visible_y_offset (
269// AutomationTrack * self);
270
279NONNULL void
281 AutomationTrack * self,
282 bool from_ticks,
283 bool bpm_change);
284
289NONNULL void
291
295NONNULL AutomationTrack *
297
298NONNULL Track *
299automation_track_get_track (AutomationTrack * self);
300
310NONNULL AutomationPoint *
312 const AutomationTrack * self,
313 const Position * pos,
314 bool ends_after,
315 bool use_snapshots);
316
326ZRegion *
328 const AutomationTrack * self,
329 const Position * pos,
330 bool ends_after,
331 bool use_snapshots);
332
336NONNULL void
338
342NONNULL void
344
349NONNULL void
351
367NONNULL float
369 AutomationTrack * self,
370 Position * pos,
371 bool normalized,
372 bool ends_after,
373 bool use_snapshots);
374
379NONNULL int
381 AutomationTrack * self,
382 float normalized_val);
383
384#if 0
385NONNULL
386Port *
387automation_track_get_port (
388 const AutomationTrack * const self);
389#endif
390
394NONNULL ZRegion *
396
397NONNULL void
398automation_track_set_caches (AutomationTrack * self, CacheTypes types);
399
400NONNULL bool
401automation_track_contains_automation (const AutomationTrack * self);
402
403NONNULL bool
404automation_track_verify (AutomationTrack * self);
405
409NONNULL void
411
412#endif // __AUDIO_AUTOMATION_TRACK_H__
Automation point API.
Ports that transfer audio/midi/other signals to one another.
A region in the timeline.
ZRegion * automation_track_get_region_before_pos(const AutomationTrack *self, const Position *pos, bool ends_after, bool use_snapshots)
Returns the ZRegion that starts before given Position, if any.
NONNULL void automation_track_remove_region(AutomationTrack *self, ZRegion *region)
Removes a region from the automation track.
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.
ZRegion * recording_region
Region currently recording to.
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_add_region(AutomationTrack *self, ZRegion *region)
Adds an automation ZRegion to the AutomationTrack.
ZRegion ** regions
The automation Region's.
NONNULL ZRegion * automation_track_get_last_region(AutomationTrack *self)
Gets the last ZRegion in the AutomationTrack.
ZRegion ** region_snapshots
Snapshots used during playback TODO unimplemented.
NONNULL void automation_track_insert_region(AutomationTrack *self, ZRegion *region, int idx)
Inserts an automation ZRegion 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.
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.
bool recording_started
To be set to true when recording starts (when the first change is received) and false when recording ...
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:139
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:126
Track to be inserted into the Project's Tracklist.
Definition track.h:177
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:72