Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
tracklist.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_TRACKLIST_H__
11#define __AUDIO_TRACKLIST_H__
12
13#include "dsp/engine.h"
14#include "dsp/track.h"
15#include "gui/widgets/track.h"
16
17typedef struct Track Track;
18typedef struct _TracklistWidget TracklistWidget;
19typedef struct _PinnedTracklistWidget PinnedTracklistWidget;
20typedef struct Track ChordTrack;
21typedef struct SupportedFile SupportedFile;
22TYPEDEF_STRUCT_UNDERSCORED (FileImportInfo);
23
30#define TRACKLIST_SCHEMA_VERSION 2
31
32#define TRACKLIST (PROJECT->tracklist)
33#define MAX_TRACKS 3000
34
35#define tracklist_is_in_active_project(self) \
36 (self->project == PROJECT \
37 || \
38 (self->sample_processor \
39 && \
40 sample_processor_is_in_active_project ( \
41 self->sample_processor)))
42
43#define tracklist_is_auditioner(self) \
44 (self->sample_processor \
45 && tracklist_is_in_active_project (self))
46
51{
52 TRACKLIST_PIN_OPTION_PINNED_ONLY,
53 TRACKLIST_PIN_OPTION_UNPINNED_ONLY,
54 TRACKLIST_PIN_OPTION_BOTH,
56
131
132static const cyaml_schema_field_t tracklist_fields_schema[] = {
133 YAML_FIELD_INT (Tracklist, schema_version),
135 Tracklist,
136 tracks,
137 track_schema),
138 YAML_FIELD_INT (Tracklist, pinned_tracks_cutoff),
139
140 CYAML_FIELD_END
141};
142
143static const cyaml_schema_value_t tracklist_schema = {
144 YAML_VALUE_PTR (Tracklist, tracklist_fields_schema),
145};
146
150COLD NONNULL_ARGS (1) void tracklist_init_loaded (
151 Tracklist * self,
152 Project * project,
153 SampleProcessor * sample_processor);
154
155COLD Tracklist *
156tracklist_new (
157 Project * project,
158 SampleProcessor * sample_processor);
159
167NONNULL void
169 Tracklist * self,
170 bool select,
171 bool fire_events);
172
176void
178 Tracklist * self,
179 Track ** visible_tracks,
180 int * num_visible);
181
186Track *
188 Tracklist * self,
189 const char * name);
190
195NONNULL OPTIMIZE_O3 Track *
197 Tracklist * self,
198 unsigned int hash);
199
200NONNULL int
201tracklist_contains_master_track (Tracklist * self);
202
203NONNULL int
204tracklist_contains_chord_track (Tracklist * self);
205
209NONNULL void
211
218NONNULL void
220 Tracklist * self,
221 Track * track,
222 int pos,
223 int publish_events,
224 int recalc_graph);
225
238NONNULL void
240 Tracklist * self,
241 Track * track,
242 bool rm_pl,
243 bool free_track,
244 bool publish_events,
245 bool recalc_graph);
246
262void
264 Tracklist * self,
265 Track * track,
266 int pos,
267 bool always_before_pos,
268 bool publish_events,
269 bool recalc_graph);
270
275void
277 Tracklist * self,
278 Track * track,
279 int publish_events,
280 int recalc_graph);
281
285void
287 Tracklist * self,
288 Track * track,
289 const int pinned,
290 int publish_events,
291 int recalc_graph);
292
293NONNULL bool
294tracklist_validate (Tracklist * self);
295
302NONNULL HOT Track *
304
308int
310
315Track *
317
318ChordTrack *
319tracklist_get_chord_track (const Tracklist * self);
320
327Track *
329 Tracklist * self,
330 const int pinned);
331
336Track *
338 Tracklist * self,
339 Track * track);
340
348int
350 Tracklist * self,
351 const TracklistPinOption pin_opt,
352 const bool visible_only);
353
361Track *
363 Tracklist * self,
364 const TracklistPinOption pin_opt,
365 const int visible_only);
366
371Track *
373 Tracklist * self,
374 Track * track);
375
384Track *
386 Tracklist * self,
387 Track * track,
388 int delta);
389
398int
400 Tracklist * self,
401 const Track * src,
402 const Track * dest);
403
410bool
412 Tracklist * self,
413 double multiplier,
414 bool visible_only,
415 bool check_only,
416 bool fire_events);
417
418bool
419tracklist_import_regions (
420 GPtrArray * region_arrays,
421 const FileImportInfo * import_info,
422 TracksReadyCallback ready_cb,
423 GError ** error);
424
438bool
440 Tracklist * self,
441 char ** uri_list,
442 const SupportedFile * orig_file,
443 Track * track,
444 TrackLane * lane,
445 int index,
446 const Position * pos,
447 TracksReadyCallback ready_cb,
448 GError ** error);
449
458void
460 Tracklist * self,
461 Track * this_track,
462 TrackWidgetHighlight location,
463 GdkDragAction action);
464
470bool
472 Tracklist * self,
473 const char * name,
474 Track * track_to_skip);
475
479NONNULL bool
481
485NONNULL bool
487
488NONNULL int
489tracklist_get_num_muted_tracks (const Tracklist * self);
490
491NONNULL int
492tracklist_get_num_soloed_tracks (const Tracklist * self);
493
494NONNULL int
495tracklist_get_num_listened_tracks (const Tracklist * self);
496
500int
502 Tracklist * self,
503 int visible);
504
510int
512 const Tracklist * const self,
513 GPtrArray * arr);
514
521void
523 Tracklist * self,
524 bool activate);
525
533void
535
539void
541 Tracklist * self,
542 bool bounce);
543
544void
545tracklist_get_total_bars (Tracklist * self, int * total_bars);
546
551NONNULL void
552tracklist_set_caches (Tracklist * self, CacheTypes types);
553
560Tracklist *
562
563void
564tracklist_free (Tracklist * self);
565
569void
571
576#endif
The backend for a timeline track.
The audio engine.
Track * tracklist_get_next_visible_track(Tracklist *self, Track *track)
Returns the next visible Track in the same Tracklist as the given one (ie, pinned or not).
Track * tracklist_get_visible_track_after_delta(Tracklist *self, Track *track, int delta)
Returns the Track after delta visible Track's.
void(* TracksReadyCallback)(const FileImportInfo *, const GError *)
Called when track(s) are actually imported into the project.
Definition track.h:1605
Track * tracklist_get_first_visible_track(Tracklist *self, const int pinned)
Returns the first visible Track.
NONNULL void tracklist_remove_track(Tracklist *self, Track *track, bool rm_pl, bool free_track, bool publish_events, bool recalc_graph)
Removes a track from the Tracklist and the TracklistSelections.
bool tracklist_multiply_track_heights(Tracklist *self, double multiplier, bool visible_only, bool check_only, bool fire_events)
Multiplies all tracks' heights and returns if the operation was valid.
void tracklist_expose_ports_to_backend(Tracklist *self)
Exposes each track's ports that should be exposed to the backend.
bool tracklist_import_files(Tracklist *self, char **uri_list, const SupportedFile *orig_file, Track *track, TrackLane *lane, int index, const Position *pos, TracksReadyCallback ready_cb, GError **error)
Begins file import Handles a file drop inside the timeline or in empty space in the tracklist.
NONNULL bool tracklist_has_soloed(const Tracklist *self)
Returns if the tracklist has soloed tracks.
Track * tracklist_find_track_by_name(Tracklist *self, const char *name)
Returns the Track matching the given name, if any.
Track * tracklist_get_track_by_type(Tracklist *self, TrackType type)
Returns the first track found with the given type.
NONNULL void tracklist_set_caches(Tracklist *self, CacheTypes types)
Set various caches (snapshots, track name hashes, plugin input/output ports, etc).
void tracklist_handle_move_or_copy(Tracklist *self, Track *this_track, TrackWidgetHighlight location, GdkDragAction action)
Handles a move or copy action based on a drag.
NONNULL void tracklist_select_all(Tracklist *self, bool select, bool fire_events)
Selects or deselects all tracks.
NONNULL OPTIMIZE_O3 Track * tracklist_find_track_by_name_hash(Tracklist *self, unsigned int hash)
Returns the Track matching the given name, if any.
bool tracklist_track_name_is_unique(Tracklist *self, const char *name, Track *track_to_skip)
Returns 1 if the track name is not taken.
void tracklist_append_track(Tracklist *self, Track *track, int publish_events, int recalc_graph)
Calls tracklist_insert_track with the given options.
void tracklist_get_visible_tracks(Tracklist *self, Track **visible_tracks, int *num_visible)
Finds visible tracks and puts them in given array.
int tracklist_get_num_visible_tracks(Tracklist *self, int visible)
NONNULL bool tracklist_has_listened(const Tracklist *self)
Returns if the tracklist has listened tracks.
int tracklist_get_visible_track_diff(Tracklist *self, const Track *src, const Track *dest)
Returns the number of visible Tracks between src and dest (negative if dest is before src).
TracklistPinOption
Used in track search functions.
Definition tracklist.h:51
int tracklist_get_track_pos(Tracklist *self, Track *track)
Returns the index of the given Track.
Tracklist * tracklist_clone(Tracklist *src)
Only clones what is needed for project save.
void tracklist_move_track(Tracklist *self, Track *track, int pos, bool always_before_pos, bool publish_events, bool recalc_graph)
Moves a track from its current position to the position given by pos.
int tracklist_get_last_pos(Tracklist *self, const TracklistPinOption pin_opt, const bool visible_only)
Returns the index of the last Track.
Track * tracklist_get_prev_visible_track(Tracklist *self, Track *track)
Returns the previous visible Track in the same Tracklist as the given one (ie, pinned or not).
void guile_tracklist_define_module(void)
Define guile module.
void tracklist_set_track_pinned(Tracklist *self, Track *track, const int pinned, int publish_events, int recalc_graph)
Pins or unpins the Track.
void tracklist_activate_all_plugins(Tracklist *self, bool activate)
Activate or deactivate all plugins.
NONNULL HOT Track * tracklist_get_track(Tracklist *self, int idx)
Returns the track at the given index or NULL if the index is invalid.
Track * tracklist_get_last_track(Tracklist *self, const TracklistPinOption pin_opt, const int visible_only)
Returns the last Track.
TrackType
The Track's type.
Definition track.h:87
COLD NONNULL_ARGS(1) void automation_track_init_loaded(AutomationTrack *self
Inits a loaded AutomationTracklist.
NONNULL void tracklist_print_tracks(Tracklist *self)
Prints the tracks (for debugging).
int tracklist_get_plugins(const Tracklist *const self, GPtrArray *arr)
Fills in the given array (if non-NULL) with all plugins in the tracklist and returns the number of pl...
void tracklist_mark_all_tracks_for_bounce(Tracklist *self, bool bounce)
Marks or unmarks all tracks for bounce.
NONNULL void tracklist_insert_track(Tracklist *self, Track *track, int pos, int publish_events, int recalc_graph)
Adds given track to given spot in tracklist.
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:221
#define YAML_FIELD_FIXED_SIZE_PTR_ARRAY_VAR_COUNT(owner, member, schema)
Fixed-width array of pointers with variable count.
Definition yaml.h:60
TrackWidgetHighlight
Highlight location.
Definition track.h:88
Track widget to be shown in the tracklist.
The PinnedTracklistWidget contains special tracks (chord, marker, etc.) as thin boxes above the norma...
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:137
Contains all of the info that will be serialized into a project file.
Definition project.h:157
A processor to be used in the routing graph for playing samples independent of the timeline.
Metadata for a supported file.
A TrackLane belongs to a Track (can have many TrackLanes in a Track) and contains Regions.
Definition track_lane.h:43
Track to be inserted into the Project's Tracklist.
Definition track.h:193
The TracklistWidget holds all the Track's in the Project.
Definition tracklist.h:44
The Tracklist contains all the tracks in the Project.
Definition tracklist.h:68
Project * project
Pointer to owner project, if any.
Definition tracklist.h:129
bool swapping_tracks
When this is true, some tracks may temporarily be moved beyond num_tracks.
Definition tracklist.h:123
Track * tempo_track
The tempo track, for convenience.
Definition tracklist.h:100
Track * chord_track
The chord track, for convenience.
Definition tracklist.h:94
Track * marker_track
The marker track, for convenience.
Definition tracklist.h:97
PinnedTracklistWidget * pinned_widget
PinnedTracklistWidget.
Definition tracklist.h:112
Track * tracks[MAX_TRACKS]
All tracks that exist.
Definition tracklist.h:89
Track * modulator_track
The modulator track, for convenience.
Definition tracklist.h:103
int pinned_tracks_cutoff
Index starting from which tracks are unpinned.
Definition tracklist.h:119
TracklistWidget * widget
Non-pinned TracklistWidget.
Definition tracklist.h:109
Track * master_track
The master track, for convenience.
Definition tracklist.h:106
SampleProcessor * sample_processor
Pointer to owner sample processor, if any.
Definition tracklist.h:126