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_wrapper.h"
39#include <zix/sem.h>
40
41typedef struct Timeline Timeline;
42typedef struct Transport Transport;
43typedef struct Tracklist Tracklist;
45
52#define PROJECT_FORMAT_MAJOR 1
53#define PROJECT_FORMAT_MINOR 10
54
55#define PROJECT gZrythm->project
56#define DEFAULT_PROJECT_NAME "Untitled Project"
57#define PROJECT_FILE "project.zpj"
58#define PROJECT_BACKUPS_DIR "backups"
59#define PROJECT_PLUGINS_DIR "plugins"
60#define PROJECT_PLUGIN_STATES_DIR "states"
61#define PROJECT_PLUGIN_EXT_COPIES_DIR "ext_file_copies"
62#define PROJECT_PLUGIN_EXT_LINKS_DIR "ext_file_links"
63#define PROJECT_EXPORTS_DIR "exports"
64#define PROJECT_STEMS_DIR "stems"
65#define PROJECT_POOL_DIR "pool"
66#define PROJECT_FINISHED_FILE "FINISHED"
67
68enum class ProjectPath
69{
70 PROJECT_PATH_PROJECT_FILE,
71 PROJECT_PATH_BACKUPS,
72
75
78
82
86
87 PROJECT_PATH_EXPORTS,
88
89 /* PROJECT_PATH_EXPORTS / "stems". */
90 PROJECT_PATH_EXPORTS_STEMS,
91
92 PROJECT_PATH_POOL,
93
94 PROJECT_PATH_FINISHED_FILE,
95};
96
124
129{
130 PROJECT_COMPRESS_FILE,
131 PROJECT_COMPRESS_DATA,
132};
133
134#define PROJECT_DECOMPRESS_FILE ProjectCompressionFlag::PROJECT_COMPRESS_FILE
135#define PROJECT_DECOMPRESS_DATA ProjectCompressionFlag::PROJECT_COMPRESS_DATA
136
296
300typedef struct ProjectSaveData
301{
304
307
308 bool is_backup;
309
312
313 bool show_notification;
314
317
318 ProgressInfo * progress_info;
320
322project_save_data_new (void);
323
324void
325project_save_data_free (ProjectSaveData * self);
326
330void
332
336bool
338
340project_get_arranger_selections_for_last_selection (Project * self);
341
342void
343project_init_common (Project * self);
344
357WARN_UNUSED_RESULT bool
359 Project * self,
360 const char * _dir,
361 const bool is_backup,
362 const bool show_notification,
363 const bool async,
364 GError ** error);
365
374int
376
377bool
378project_make_project_dirs (Project * self, bool is_backup, GError ** error);
379
387MALLOC
388NONNULL char *
389project_get_path (Project * self, ProjectPath path, bool backup);
390
397COLD void
399
416bool
418 bool compress,
419 char ** _dest,
420 size_t * _dest_size,
421 ProjectCompressionFlag dest_type,
422 const char * _src,
423 const size_t _src_size,
424 ProjectCompressionFlag src_type,
425 GError ** error);
426
427#define project_compress(a, b, c, d, e, f, error) \
428 _project_compress (true, a, b, c, d, e, f, error)
429
430#define project_decompress(a, b, c, d, e, f, error) \
431 _project_compress (false, a, b, c, d, e, f, error)
432
440char *
442 Project * self,
443 bool backup,
444 GError ** error);
445
449NONNULL bool
450project_has_unsaved_changes (const Project * self);
451
460NONNULL Project *
461project_clone (const Project * src, bool for_backup, GError ** error);
462
466COLD NONNULL Project *
468
472void
474
479#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.
To be used throughout the program.
Definition zrythm.h:216
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.
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:69
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 void project_init_selections(Project *self)
Initializes the selections in the project.
COLD NONNULL Project * project_new(Zrythm *owner)
Creates an empty project object.
ProjectCompressionFlag
Flag to pass to project_compress() and project_decompress().
Definition project.h:129
ProjectSelectionType
Selection type, used for controlling which part of the interface is selected, for copy-paste,...
Definition project.h:102
MALLOC NONNULL char * project_get_path(Project *self, ProjectPath path, bool backup)
Returns the requested project path as a newly allocated string.
@ PROJECT_PATH_PLUGIN_STATES
Path for state .ttl files.
@ PROJECT_PATH_PLUGINS
Plugins path.
@ PROJECT_PATH_PLUGIN_EXT_COPIES
External files for plugin states, under the STATES dir.
@ PROJECT_PATH_PLUGIN_EXT_LINKS
External files for plugin states, under the STATES dir.
@ Z_PROJECT_SELECTION_TYPE_MODULATOR
Modulator slot.
@ Z_PROJECT_SELECTION_TYPE_INSERT
Insert selections in the mixer.
@ Z_PROJECT_SELECTION_TYPE_EDITOR
Editor arranger.
@ Z_PROJECT_SELECTION_TYPE_TRACKLIST
Track selection in tracklist or mixer.
@ Z_PROJECT_SELECTION_TYPE_INSTRUMENT
Instrument slot.
@ Z_PROJECT_SELECTION_TYPE_MIDI_FX
MIDI FX selections in the mixer.
@ Z_PROJECT_SELECTION_TYPE_TIMELINE
Timeline or pinned timeline.
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:353
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:37
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:301
bool has_error
Whether an error occurred during saving.
Definition project.h:316
Project * project
Project clone (with memcpy).
Definition project.h:303
char * project_file_path
Full path to save to.
Definition project.h:306
bool finished
To be set to true when the thread finishes.
Definition project.h:311
Contains all of the info that will be serialized into a project file.
Definition project.h:145
ChordSelections * chord_selections
Selected objects in the ChordObjectArrangerWidget.
Definition project.h:201
TimelineSelections * timeline_selections
Selected objects in the TimelineArrangerWidget.
Definition project.h:206
Timeline * timeline
Timeline widget backend.
Definition project.h:172
Tool tool
Currently selected tool (select - normal, select - stretch, edit, delete, ramp, audition)
Definition project.h:244
ZixSem save_sem
Semaphore used to block saving.
Definition project.h:276
char * dir
Path to save the project in.
Definition project.h:153
bool loaded
If a project is currently loaded or not.
Definition project.h:263
QuantizeOptions * quantize_opts_editor
Quantize info for the piano roll.
Definition project.h:184
ProjectSelectionType last_selection
The last thing selected in the GUI.
Definition project.h:270
SnapGrid * snap_grid_editor
Snap/Grid info for the editor.
Definition project.h:178
MidiArrangerSelections * midi_arranger_selections
Selected MidiNote's in the MidiArrangerWidget.
Definition project.h:211
UndoableAction * last_saved_action
Used to check if the project has unsaved changes.
Definition project.h:280
QuantizeOptions * quantize_opts_timeline
Quantize info for the timeline.
Definition project.h:181
SnapGrid * snap_grid_timeline
Snap/Grid info for the timeline.
Definition project.h:175
double timeline_zoom
Zoom levels.
Definition project.h:224
AudioEngine * audio_engine
The audio backend.
Definition project.h:235
AutomationSelections * automation_selections
Selected objects in the AutomationArrangerWidget.
Definition project.h:190
char * backup_dir
Backup dir to save the project during the current save call.
Definition project.h:162
int format_major
Used when deserializing projects.
Definition project.h:293
MixerSelections * mixer_selections
Plugin selections in the Mixer.
Definition project.h:221
bool loading_from_backup
Whether the current is currently being loaded from a backup file.
Definition project.h:254
gint64 last_successful_autosave_time
Last successful autosave timestamp.
Definition project.h:283
RegionLinkGroupManager * region_link_group_manager
Manager for region link groups.
Definition project.h:228
UndoableAction * last_action_in_last_successful_autosave
Last undoable action in the previous successful autosave.
Definition project.h:290
char * title
Project title.
Definition project.h:147
char * datetime_str
Datetime string to add to the project file.
Definition project.h:150
ClipEditor * clip_editor
Backend for the widget.
Definition project.h:169
TracklistSelections * tracklist_selections
Selected Track's.
Definition project.h:216
AudioSelections * audio_selections
Selected objects in the audio editor.
Definition project.h:195
char * version
Zrythm version, for serialization.
Definition project.h:273
MidiMappings * midi_mappings
MIDI bindings.
Definition project.h:238
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:151
Undo manager.
Base struct to be inherited by implementing undoable actions.
Timeline backend.
Current TimelineArranger selections.
Undo manager.
The main Zrythm struct.