Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
Project

Data Structures

struct  Project
 Contains all of the info that will be serialized into a project file. More...
 
struct  ProjectSaveData
 Project save data. More...
 
struct  Settings
 

Macros

#define PROJECT_FORMAT_MAJOR   1
 
#define PROJECT_FORMAT_MINOR   10
 
#define PROJECT   ZRYTHM->project
 
#define DEFAULT_PROJECT_NAME   "Untitled Project"
 
#define PROJECT_FILE   "project.zpj"
 
#define PROJECT_BACKUPS_DIR   "backups"
 
#define PROJECT_PLUGINS_DIR   "plugins"
 
#define PROJECT_PLUGIN_STATES_DIR   "states"
 
#define PROJECT_PLUGIN_EXT_COPIES_DIR   "ext_file_copies"
 
#define PROJECT_PLUGIN_EXT_LINKS_DIR   "ext_file_links"
 
#define PROJECT_EXPORTS_DIR   "exports"
 
#define PROJECT_STEMS_DIR   "stems"
 
#define PROJECT_POOL_DIR   "pool"
 
#define PROJECT_FINISHED_FILE   "FINISHED"
 
#define PROJECT_DECOMPRESS_FILE   PROJECT_COMPRESS_FILE
 
#define PROJECT_DECOMPRESS_DATA   PROJECT_COMPRESS_DATA
 
#define project_compress(a, b, c, d, e, f, error)    _project_compress (true, a, b, c, d, e, f, error)
 
#define project_decompress(a, b, c, d, e, f, error)    _project_compress (false, a, b, c, d, e, f, error)
 
#define GSETTINGS_ZRYTHM_PREFIX   "org.zrythm.Zrythm"
 
#define SETTINGS   (ZRYTHM->settings)
 
#define S_MONITOR   SETTINGS->monitor
 
#define S_UI   SETTINGS->ui
 
#define S_EXPORT_AUDIO   SETTINGS->export_audio
 
#define S_EXPORT_MIDI   SETTINGS->export_midi
 
#define S_GENERAL   SETTINGS->general
 
#define S_UI_INSPECTOR   SETTINGS->ui_inspector
 
#define S_UI_MIXER   SETTINGS->ui_mixer
 
#define S_UI_PANELS   SETTINGS->ui_panels
 
#define S_UI_PLUGIN_BROWSER   SETTINGS->ui_plugin_browser
 
#define S_UI_FILE_BROWSER   SETTINGS->ui_file_browser
 
#define S_TRANSPORT   SETTINGS->transport
 
#define S_P_DSP_PAN   SETTINGS->preferences_dsp_pan
 
#define S_P_EDITING_AUDIO   SETTINGS->preferences_editing_audio
 
#define S_P_EDITING_AUTOMATION   SETTINGS->preferences_editing_automation
 
#define S_P_EDITING_UNDO   SETTINGS->preferences_editing_undo
 
#define S_P_GENERAL_ENGINE   SETTINGS->preferences_general_engine
 
#define S_P_GENERAL_PATHS   SETTINGS->preferences_general_paths
 
#define S_P_GENERAL_UPDATES   SETTINGS->preferences_general_updates
 
#define S_P_PLUGINS_UIS   SETTINGS->preferences_plugins_uis
 
#define S_P_PLUGINS_PATHS   SETTINGS->preferences_plugins_paths
 
#define S_P_PROJECTS_GENERAL   SETTINGS->preferences_projects_general
 
#define S_P_UI_GENERAL   SETTINGS->preferences_ui_general
 
#define S_P_SCRIPTING_GENERAL   SETTINGS->preferences_scripting_general
 
#define S_IS_DEBUG   (g_settings_get_int (S_GENERAL, "debug"))
 
#define S_SET_ENUM(settings, key, val)   g_settings_set_enum (settings, key, val)
 
#define S_GET_ENUM(settings, key)   g_settings_get_enum (settings, key)
 
#define S_UI_SET_ENUM(key, val)   S_SET_ENUM (S_UI, key, val)
 
#define S_UI_GET_ENUM(key)   S_GET_ENUM (S_UI, key)
 
#define S_PLUGIN_SETTINGS   SETTINGS->plugin_settings
 
#define S_USER_SHORTCUTS   SETTINGS->user_shortcuts
 

Typedefs

typedef void(* ProjectInitDoneCallback) (bool success, GError *error, void *user_data)
 Callback to call when project initialization (loading or creating new) finishes.
 

Enumerations

enum  ProjectPath {
  PROJECT_PATH_PROJECT_FILE , PROJECT_PATH_BACKUPS , PROJECT_PATH_PLUGINS , PROJECT_PATH_PLUGIN_STATES ,
  PROJECT_PATH_PLUGIN_EXT_COPIES , PROJECT_PATH_PLUGIN_EXT_LINKS , PROJECT_PATH_EXPORTS , PROJECT_PATH_EXPORTS_STEMS ,
  PROJECT_PATH_POOL , PROJECT_PATH_FINISHED_FILE
}
 
enum  SelectionType {
  SELECTION_TYPE_TRACKLIST , SELECTION_TYPE_TIMELINE , SELECTION_TYPE_INSERT , SELECTION_TYPE_MIDI_FX ,
  SELECTION_TYPE_INSTRUMENT , SELECTION_TYPE_MODULATOR , SELECTION_TYPE_EDITOR
}
 Selection type, used for controlling which part of the interface is selected, for copy-paste, displaying info in the inspector, etc. More...
 
enum  ProjectCompressionFlag { PROJECT_COMPRESS_FILE , PROJECT_COMPRESS_DATA }
 Flag to pass to project_compress() and project_decompress(). More...
 

Functions

ProjectSaveDataproject_save_data_new (void)
 
void project_save_data_free (ProjectSaveData *self)
 
void project_validate (Project *self)
 Checks that everything is okay with the project.
 
bool project_fix_audio_regions (Project *self)
 
ArrangerSelectionsproject_get_arranger_selections_for_last_selection (Project *self)
 
void project_init_common (Project *self)
 
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.
 
int project_autosave_cb (void *data)
 Autosave callback.
 
bool project_make_project_dirs (Project *self, bool is_backup, GError **error)
 
MALLOC NONNULL char * project_get_path (Project *self, ProjectPath path, bool backup)
 Returns the requested project path as a newly allocated string.
 
COLD void project_init_selections (Project *self)
 Initializes the selections in the project.
 
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.
 
char * project_get_existing_uncompressed_text (Project *self, bool backup, GError **error)
 Returns the uncompressed text representation of the saved project file.
 
NONNULL Projectproject_clone (const Project *src, bool for_backup, GError **error)
 Deep-clones the given project.
 
COLD Projectproject_new (Zrythm *zrythm)
 Creates an empty project object.
 
void project_free (Project *self)
 Tears down the project.
 
void project_init_flow_manager_load_or_create_default_project (const char *filename, const bool is_template, ProjectInitDoneCallback cb, void *user_data)
 If filename set, it loads that, otherwise it loads the default project.
 
Settingssettings_new (void)
 Initializes settings.
 
void settings_reset_to_factory (bool confirm, bool exit_on_finish)
 Resets settings to defaults.
 
void settings_print (int pretty_print)
 Prints the current settings.
 
NONNULL bool settings_strv_contains_str (GSettings *settings, const char *key, const char *val)
 Returns whether the "as" key contains the given string.
 
NONNULL void settings_append_to_strv (GSettings *settings, const char *key, const char *val, bool ignore_if_duplicate)
 Appends the given string to a key of type "as".
 
GVariant * settings_get_range (const char *schema, const char *key)
 
void settings_get_range_double (const char *schema, const char *key, double *lower, double *upper)
 
GVariant * settings_get_default_value (const char *schema, const char *key)
 
double settings_get_default_value_double (const char *schema, const char *key)
 
char * settings_get_summary (GSettings *settings, const char *key)
 Returns the localized summary as a newly allocated string.
 
char * settings_get_description (GSettings *settings, const char *key)
 Returns the localized description as a newly allocated string.
 
void settings_free (Settings *self)
 Frees settings.
 
NONNULL bool Project::project_has_unsaved_changes (const Project *self)
 

Detailed Description

Project initialization, saving and loading.

Macro Definition Documentation

◆ DEFAULT_PROJECT_NAME

#define DEFAULT_PROJECT_NAME   "Untitled Project"

Definition at line 57 of file project.h.

◆ GSETTINGS_ZRYTHM_PREFIX

#define GSETTINGS_ZRYTHM_PREFIX   "org.zrythm.Zrythm"

Definition at line 26 of file settings.h.

◆ PROJECT

#define PROJECT   ZRYTHM->project

Definition at line 56 of file project.h.

◆ PROJECT_BACKUPS_DIR

#define PROJECT_BACKUPS_DIR   "backups"

Definition at line 59 of file project.h.

◆ project_compress

#define project_compress ( a,
b,
c,
d,
e,
f,
error )    _project_compress (true, a, b, c, d, e, f, error)

Definition at line 440 of file project.h.

◆ project_decompress

#define project_decompress ( a,
b,
c,
d,
e,
f,
error )    _project_compress (false, a, b, c, d, e, f, error)

Definition at line 443 of file project.h.

◆ PROJECT_DECOMPRESS_DATA

#define PROJECT_DECOMPRESS_DATA   PROJECT_COMPRESS_DATA

Definition at line 148 of file project.h.

◆ PROJECT_DECOMPRESS_FILE

#define PROJECT_DECOMPRESS_FILE   PROJECT_COMPRESS_FILE

Definition at line 147 of file project.h.

◆ PROJECT_EXPORTS_DIR

#define PROJECT_EXPORTS_DIR   "exports"

Definition at line 64 of file project.h.

◆ PROJECT_FILE

#define PROJECT_FILE   "project.zpj"

Definition at line 58 of file project.h.

◆ PROJECT_FINISHED_FILE

#define PROJECT_FINISHED_FILE   "FINISHED"

Definition at line 67 of file project.h.

◆ PROJECT_FORMAT_MAJOR

#define PROJECT_FORMAT_MAJOR   1

Definition at line 53 of file project.h.

◆ PROJECT_FORMAT_MINOR

#define PROJECT_FORMAT_MINOR   10

Definition at line 54 of file project.h.

◆ PROJECT_PLUGIN_EXT_COPIES_DIR

#define PROJECT_PLUGIN_EXT_COPIES_DIR   "ext_file_copies"

Definition at line 62 of file project.h.

◆ PROJECT_PLUGIN_EXT_LINKS_DIR

#define PROJECT_PLUGIN_EXT_LINKS_DIR   "ext_file_links"

Definition at line 63 of file project.h.

◆ PROJECT_PLUGIN_STATES_DIR

#define PROJECT_PLUGIN_STATES_DIR   "states"

Definition at line 61 of file project.h.

◆ PROJECT_PLUGINS_DIR

#define PROJECT_PLUGINS_DIR   "plugins"

Definition at line 60 of file project.h.

◆ PROJECT_POOL_DIR

#define PROJECT_POOL_DIR   "pool"

Definition at line 66 of file project.h.

◆ PROJECT_STEMS_DIR

#define PROJECT_STEMS_DIR   "stems"

Definition at line 65 of file project.h.

◆ S_EXPORT_AUDIO

#define S_EXPORT_AUDIO   SETTINGS->export_audio

Definition at line 32 of file settings.h.

◆ S_EXPORT_MIDI

#define S_EXPORT_MIDI   SETTINGS->export_midi

Definition at line 33 of file settings.h.

◆ S_GENERAL

#define S_GENERAL   SETTINGS->general

Definition at line 34 of file settings.h.

◆ S_GET_ENUM

#define S_GET_ENUM ( settings,
key )   g_settings_get_enum (settings, key)

Definition at line 64 of file settings.h.

◆ S_IS_DEBUG

#define S_IS_DEBUG   (g_settings_get_int (S_GENERAL, "debug"))

Definition at line 60 of file settings.h.

◆ S_MONITOR

#define S_MONITOR   SETTINGS->monitor

Definition at line 30 of file settings.h.

◆ S_P_DSP_PAN

#define S_P_DSP_PAN   SETTINGS->preferences_dsp_pan

Definition at line 45 of file settings.h.

◆ S_P_EDITING_AUDIO

#define S_P_EDITING_AUDIO   SETTINGS->preferences_editing_audio

Definition at line 46 of file settings.h.

◆ S_P_EDITING_AUTOMATION

#define S_P_EDITING_AUTOMATION   SETTINGS->preferences_editing_automation

Definition at line 47 of file settings.h.

◆ S_P_EDITING_UNDO

#define S_P_EDITING_UNDO   SETTINGS->preferences_editing_undo

Definition at line 48 of file settings.h.

◆ S_P_GENERAL_ENGINE

#define S_P_GENERAL_ENGINE   SETTINGS->preferences_general_engine

Definition at line 49 of file settings.h.

◆ S_P_GENERAL_PATHS

#define S_P_GENERAL_PATHS   SETTINGS->preferences_general_paths

Definition at line 50 of file settings.h.

◆ S_P_GENERAL_UPDATES

#define S_P_GENERAL_UPDATES   SETTINGS->preferences_general_updates

Definition at line 51 of file settings.h.

◆ S_P_PLUGINS_PATHS

#define S_P_PLUGINS_PATHS   SETTINGS->preferences_plugins_paths

Definition at line 53 of file settings.h.

◆ S_P_PLUGINS_UIS

#define S_P_PLUGINS_UIS   SETTINGS->preferences_plugins_uis

Definition at line 52 of file settings.h.

◆ S_P_PROJECTS_GENERAL

#define S_P_PROJECTS_GENERAL   SETTINGS->preferences_projects_general

Definition at line 54 of file settings.h.

◆ S_P_SCRIPTING_GENERAL

#define S_P_SCRIPTING_GENERAL   SETTINGS->preferences_scripting_general

Definition at line 56 of file settings.h.

◆ S_P_UI_GENERAL

#define S_P_UI_GENERAL   SETTINGS->preferences_ui_general

Definition at line 55 of file settings.h.

◆ S_PLUGIN_SETTINGS

#define S_PLUGIN_SETTINGS   SETTINGS->plugin_settings

Definition at line 70 of file settings.h.

◆ S_SET_ENUM

#define S_SET_ENUM ( settings,
key,
val )   g_settings_set_enum (settings, key, val)

Definition at line 62 of file settings.h.

◆ S_TRANSPORT

#define S_TRANSPORT   SETTINGS->transport

Definition at line 40 of file settings.h.

◆ S_UI

#define S_UI   SETTINGS->ui

Definition at line 31 of file settings.h.

◆ S_UI_FILE_BROWSER

#define S_UI_FILE_BROWSER   SETTINGS->ui_file_browser

Definition at line 39 of file settings.h.

◆ S_UI_GET_ENUM

#define S_UI_GET_ENUM ( key)    S_GET_ENUM (S_UI, key)

Definition at line 68 of file settings.h.

◆ S_UI_INSPECTOR

#define S_UI_INSPECTOR   SETTINGS->ui_inspector

Definition at line 35 of file settings.h.

◆ S_UI_MIXER

#define S_UI_MIXER   SETTINGS->ui_mixer

Definition at line 36 of file settings.h.

◆ S_UI_PANELS

#define S_UI_PANELS   SETTINGS->ui_panels

Definition at line 37 of file settings.h.

◆ S_UI_PLUGIN_BROWSER

#define S_UI_PLUGIN_BROWSER   SETTINGS->ui_plugin_browser

Definition at line 38 of file settings.h.

◆ S_UI_SET_ENUM

#define S_UI_SET_ENUM ( key,
val )   S_SET_ENUM (S_UI, key, val)

Definition at line 66 of file settings.h.

◆ S_USER_SHORTCUTS

#define S_USER_SHORTCUTS   SETTINGS->user_shortcuts

Definition at line 72 of file settings.h.

◆ SETTINGS

#define SETTINGS   (ZRYTHM->settings)

Definition at line 27 of file settings.h.

Typedef Documentation

◆ ProjectInitDoneCallback

typedef void( * ProjectInitDoneCallback) (bool success, GError *error, void *user_data)

Callback to call when project initialization (loading or creating new) finishes.

Definition at line 25 of file project_init_flow_manager.h.

Enumeration Type Documentation

◆ ProjectCompressionFlag

Flag to pass to project_compress() and project_decompress().

Definition at line 141 of file project.h.

◆ ProjectPath

Enumerator
PROJECT_PATH_PLUGINS 

Plugins path.

PROJECT_PATH_PLUGIN_STATES 

Path for state .ttl files.

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.

Definition at line 69 of file project.h.

◆ SelectionType

Selection type, used for controlling which part of the interface is selected, for copy-paste, displaying info in the inspector, etc.

Enumerator
SELECTION_TYPE_TRACKLIST 

Track selection in tracklist or mixer.

SELECTION_TYPE_TIMELINE 

Timeline or pinned timeline.

SELECTION_TYPE_INSERT 

Insert selections in the mixer.

SELECTION_TYPE_MIDI_FX 

MIDI FX selections in the mixer.

SELECTION_TYPE_INSTRUMENT 

Instrument slot.

SELECTION_TYPE_MODULATOR 

Modulator slot.

SELECTION_TYPE_EDITOR 

Editor arranger.

Definition at line 103 of file project.h.

Function Documentation

◆ _project_compress()

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.

Parameters
compressTrue to compress, false to decompress.
[out]_destPointer to a location to allocate memory.
[out]_dest_sizePointer to a location to store the size of the allocated memory.
_srcInput buffer or filepath.
_src_sizeInput buffer size, if not filepath.
Returns
Whether successful.

◆ project_autosave_cb()

int project_autosave_cb ( void * data)

Autosave callback.

This will keep getting called at regular short intervals, and if enough time has passed and it's okay to save it will autosave, otherwise it will wait until the next interval and check again.

◆ project_clone()

NONNULL Project * project_clone ( const Project * src,
bool for_backup,
GError ** error )

Deep-clones the given project.

To be used during save on the main thread.

Parameters
for_backupWhether the resulting project is for a backup.

◆ project_fix_audio_regions()

bool project_fix_audio_regions ( Project * self)
Returns
Whether positions were adjusted.

◆ project_get_existing_uncompressed_text()

char * project_get_existing_uncompressed_text ( Project * self,
bool backup,
GError ** error )

Returns the uncompressed text representation of the saved project file.

To be free'd with free().

Parameters
backupWhether to use the project file from the most recent backup.

◆ project_get_path()

MALLOC NONNULL char * project_get_path ( Project * self,
ProjectPath path,
bool backup )

Returns the requested project path as a newly allocated string.

Parameters
backupWhether to get the path for the current backup instead of the main project.

◆ project_init_flow_manager_load_or_create_default_project()

void project_init_flow_manager_load_or_create_default_project ( const char * filename,
const bool is_template,
ProjectInitDoneCallback cb,
void * user_data )

If filename set, it loads that, otherwise it loads the default project.

Note
This function is async when running normally.
Parameters
filenameThe filename to open. This will be the template in the case of template, or the actual project otherwise.
is_templateLoad the project as a template and create a new project from it.
cbCallback to call when finished.
user_dataUser data to pass to cb.

◆ project_init_selections()

COLD void project_init_selections ( Project * self)

Initializes the selections in the project.

Note
Not meant to be used anywhere besides tests and project.c

◆ project_save()

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.

Parameters
is_backup1 if this is a backup. Backups will be saved as <original filename>.bak<num>.
show_notificationShow a notification in the UI that the project was saved.
asyncSave asynchronously in another thread.
Returns
Whether successful.

◆ settings_reset_to_factory()

void settings_reset_to_factory ( bool confirm,
bool exit_on_finish )

Resets settings to defaults.

Parameters
confirmShow command line confirmation option.
exit_on_finishExit with a code on finish.