Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
project.h
1// SPDX-FileCopyrightText: © 2018-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
13#ifndef __PROJECT_H__
14#define __PROJECT_H__
15
17#include "dsp/engine.h"
18#include "dsp/midi_mapping.h"
19#include "dsp/midi_note.h"
20#include "dsp/port.h"
23#include "dsp/region.h"
25#include "dsp/tracklist.h"
34#include "gui/backend/tool.h"
35#include "plugins/plugin.h"
36#include "zrythm.h"
37
38#include <gtk/gtk.h>
39
40#include <zix/sem.h>
41
42typedef struct Timeline Timeline;
43typedef struct Transport Transport;
44typedef struct Tracklist Tracklist;
46
53#define PROJECT_FORMAT_MAJOR 1
54#define PROJECT_FORMAT_MINOR 10
55
56#define PROJECT ZRYTHM->project
57#define DEFAULT_PROJECT_NAME "Untitled Project"
58#define PROJECT_FILE "project.zpj"
59#define PROJECT_BACKUPS_DIR "backups"
60#define PROJECT_PLUGINS_DIR "plugins"
61#define PROJECT_PLUGIN_STATES_DIR "states"
62#define PROJECT_PLUGIN_EXT_COPIES_DIR "ext_file_copies"
63#define PROJECT_PLUGIN_EXT_LINKS_DIR "ext_file_links"
64#define PROJECT_EXPORTS_DIR "exports"
65#define PROJECT_STEMS_DIR "stems"
66#define PROJECT_POOL_DIR "pool"
67#define PROJECT_FINISHED_FILE "FINISHED"
68
69typedef enum ProjectPath
70{
71 PROJECT_PATH_PROJECT_FILE,
72 PROJECT_PATH_BACKUPS,
73
76
79
83
87
88 PROJECT_PATH_EXPORTS,
89
90 /* PROJECT_PATH_EXPORTS / "stems". */
91 PROJECT_PATH_EXPORTS_STEMS,
92
93 PROJECT_PATH_POOL,
94
95 PROJECT_PATH_FINISHED_FILE,
97
125
130{
131 PROJECT_COMPRESS_FILE,
132 PROJECT_COMPRESS_DATA,
134
135#define PROJECT_DECOMPRESS_FILE PROJECT_COMPRESS_FILE
136#define PROJECT_DECOMPRESS_DATA PROJECT_COMPRESS_DATA
137
297
301typedef struct ProjectSaveData
302{
305
308
309 bool is_backup;
310
313
314 bool show_notification;
315
318
319 ProgressInfo * progress_info;
321
323project_save_data_new (void);
324
325void
326project_save_data_free (ProjectSaveData * self);
327
331void
333
337bool
339
341project_get_arranger_selections_for_last_selection (Project * self);
342
343void
344project_init_common (Project * self);
345
358WARN_UNUSED_RESULT bool
360 Project * self,
361 const char * _dir,
362 const bool is_backup,
363 const bool show_notification,
364 const bool async,
365 GError ** error);
366
375int
377
378bool
379project_make_project_dirs (Project * self, bool is_backup, GError ** error);
380
388MALLOC
389NONNULL char *
390project_get_path (Project * self, ProjectPath path, bool backup);
391
398COLD void
400
417bool
419 bool compress,
420 char ** _dest,
421 size_t * _dest_size,
422 ProjectCompressionFlag dest_type,
423 const char * _src,
424 const size_t _src_size,
425 ProjectCompressionFlag src_type,
426 GError ** error);
427
428#define project_compress(a, b, c, d, e, f, error) \
429 _project_compress (true, a, b, c, d, e, f, error)
430
431#define project_decompress(a, b, c, d, e, f, error) \
432 _project_compress (false, a, b, c, d, e, f, error)
433
441char *
443 Project * self,
444 bool backup,
445 GError ** error);
446
450NONNULL bool
451project_has_unsaved_changes (const Project * self);
452
461NONNULL Project *
462project_clone (const Project * src, bool for_backup, GError ** error);
463
467COLD Project *
469
473void
475
480#endif
API for selections in the AudioArrangerWidget.
API for selections in the AutomationArrangerWidget.
The clip/region editor backend.
API for selections in the piano roll.
The audio engine.
API for MIDI notes in the PianoRoll.
Ports that transfer audio/midi/other signals to one another.
A region in the timeline.
Tracklist backend.
Zrythm * zrythm
Global variable, should be available to all files.
bool project_fix_audio_regions(Project *self)
void project_free(Project *self)
Tears down the project.
NONNULL Project * project_clone(const Project *src, bool for_backup, GError **error)
Deep-clones the given project.
void project_validate(Project *self)
Checks that everything is okay with the project.
int project_autosave_cb(void *data)
Autosave callback.
bool _project_compress(bool compress, char **_dest, size_t *_dest_size, ProjectCompressionFlag dest_type, const char *_src, const size_t _src_size, ProjectCompressionFlag src_type, GError **error)
Compresses/decompress a project from a file/data to a file/data.
ProjectPath
Definition project.h:70
WARN_UNUSED_RESULT bool project_save(Project *self, const char *_dir, const bool is_backup, const bool show_notification, const bool async, GError **error)
Saves the project to a project file in the given dir.
char * project_get_existing_uncompressed_text(Project *self, bool backup, GError **error)
Returns the uncompressed text representation of the saved project file.
COLD Project * project_new(Zrythm *zrythm)
Creates an empty project object.
COLD void project_init_selections(Project *self)
Initializes the selections in the project.
ProjectCompressionFlag
Flag to pass to project_compress() and project_decompress().
Definition project.h:130
MALLOC NONNULL char * project_get_path(Project *self, ProjectPath path, bool backup)
Returns the requested project path as a newly allocated string.
ZProjectSelectionType
Selection type, used for controlling which part of the interface is selected, for copy-paste,...
Definition project.h:103
@ PROJECT_PATH_PLUGINS
Plugins path.
Definition project.h:75
@ PROJECT_PATH_PLUGIN_EXT_COPIES
External files for plugin states, under the STATES dir.
Definition project.h:82
@ PROJECT_PATH_PLUGIN_STATES
Path for state .ttl files.
Definition project.h:78
@ PROJECT_PATH_PLUGIN_EXT_LINKS
External files for plugin states, under the STATES dir.
Definition project.h:86
@ Z_PROJECT_SELECTION_TYPE_TRACKLIST
Track selection in tracklist or mixer.
Definition project.h:105
@ Z_PROJECT_SELECTION_TYPE_MODULATOR
Modulator slot.
Definition project.h:120
@ Z_PROJECT_SELECTION_TYPE_INSERT
Insert selections in the mixer.
Definition project.h:111
@ Z_PROJECT_SELECTION_TYPE_MIDI_FX
MIDI FX selections in the mixer.
Definition project.h:114
@ Z_PROJECT_SELECTION_TYPE_INSTRUMENT
Instrument slot.
Definition project.h:117
@ Z_PROJECT_SELECTION_TYPE_TIMELINE
Timeline or pinned timeline.
Definition project.h:108
@ Z_PROJECT_SELECTION_TYPE_EDITOR
Editor arranger.
Definition project.h:123
API for selections in the piano roll.
Mapping MIDI CC to controls.
Mixer selections.
Base plugin.
Port connections manager.
Quantize options.
The audio engine.
Definition engine.h:358
Selections to be used for the AudioArrangerWidget's current selections, copying, undoing,...
Selections to be used for the AutomationArrangerWidget's current selections, copying,...
Selections to be used for the ChordArrangerWidget's current selections, copying, undoing,...
Clip editor serializable backend.
Definition clip_editor.h:39
A collection of selected MidiNote's.
All MIDI mappings in Zrythm.
Selections to be used for the timeline's current selections, copying, undoing, etc.
Port connections manager.
Project save data.
Definition project.h:302
bool has_error
Whether an error occurred during saving.
Definition project.h:317
Project * project
Project clone (with memcpy).
Definition project.h:304
char * project_file_path
Full path to save to.
Definition project.h:307
bool finished
To be set to true when the thread finishes.
Definition project.h:312
Contains all of the info that will be serialized into a project file.
Definition project.h:146
ChordSelections * chord_selections
Selected objects in the ChordObjectArrangerWidget.
Definition project.h:202
TimelineSelections * timeline_selections
Selected objects in the TimelineArrangerWidget.
Definition project.h:207
Timeline * timeline
Timeline widget backend.
Definition project.h:173
Tool tool
Currently selected tool (select - normal, select - stretch, edit, delete, ramp, audition)
Definition project.h:245
ZixSem save_sem
Semaphore used to block saving.
Definition project.h:277
char * dir
Path to save the project in.
Definition project.h:154
bool loaded
If a project is currently loaded or not.
Definition project.h:264
QuantizeOptions * quantize_opts_editor
Quantize info for the piano roll.
Definition project.h:185
SnapGrid * snap_grid_editor
Snap/Grid info for the editor.
Definition project.h:179
MidiArrangerSelections * midi_arranger_selections
Selected MidiNote's in the MidiArrangerWidget.
Definition project.h:212
UndoableAction * last_saved_action
Used to check if the project has unsaved changes.
Definition project.h:281
QuantizeOptions * quantize_opts_timeline
Quantize info for the timeline.
Definition project.h:182
SnapGrid * snap_grid_timeline
Snap/Grid info for the timeline.
Definition project.h:176
double timeline_zoom
Zoom levels.
Definition project.h:225
AudioEngine * audio_engine
The audio backend.
Definition project.h:236
AutomationSelections * automation_selections
Selected objects in the AutomationArrangerWidget.
Definition project.h:191
ZProjectSelectionType last_selection
The last thing selected in the GUI.
Definition project.h:271
char * backup_dir
Backup dir to save the project during the current save call.
Definition project.h:163
int format_major
Used when deserializing projects.
Definition project.h:294
MixerSelections * mixer_selections
Plugin selections in the Mixer.
Definition project.h:222
bool loading_from_backup
Whether the current is currently being loaded from a backup file.
Definition project.h:255
gint64 last_successful_autosave_time
Last successful autosave timestamp.
Definition project.h:284
RegionLinkGroupManager * region_link_group_manager
Manager for region link groups.
Definition project.h:229
UndoableAction * last_action_in_last_successful_autosave
Last undoable action in the previous successful autosave.
Definition project.h:291
char * title
Project title.
Definition project.h:148
char * datetime_str
Datetime string to add to the project file.
Definition project.h:151
ClipEditor * clip_editor
Backend for the widget.
Definition project.h:170
TracklistSelections * tracklist_selections
Selected Track's.
Definition project.h:217
AudioSelections * audio_selections
Selected objects in the audio editor.
Definition project.h:196
char * version
Zrythm version, for serialization.
Definition project.h:274
MidiMappings * midi_mappings
MIDI bindings.
Definition project.h:239
Manager of region link groups.
Selections to be used for the timeline's current selections, copying, undoing, etc.
Clip editor serializable backend.
Definition timeline.h:30
Selections to be used for the tracklist's current selections, copying, undoing, etc.
The Tracklist contains all the tracks in the Project.
Definition tracklist.h:61
The transport.
Definition transport.h:148
Undo manager.
Base struct to be inherited by implementing undoable actions.
To be used throughout the program.
Definition zrythm.h:188
Timeline backend.
Current TimelineArranger selections.
Undo manager.
The main Zrythm struct.