Project module

Project initialization, saving and loading.

Contents

Classes

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

Enums

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 }
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.
enum ProjectCompressionFlag { PROJECT_COMPRESS_FILE, PROJECT_COMPRESS_DATA }
Flag to pass to project_compress() and project_decompress().

Typedefs

using SelectionType = enum SelectionType
Selection type, used for controlling which part of the interface is selected, for copy-paste, displaying info in the inspector, etc.
using ProjectCompressionFlag = enum ProjectCompressionFlag
Flag to pass to project_compress() and project_decompress().
using Project = struct Project
Contains all of the info that will be serialized into a project file.
using ProjectSaveData = struct ProjectSaveData
Projet save data.

Functions

void project_validate(Project* self)
Checks that everything is okay with the project.
auto project_create_default(Project* self, const char* prj_dir, bool headless, bool with_engine) -> COLD Project*
Creates a default project.
auto project_load(const char* filename, const bool is_template) -> COLD int
If project has a filename set, it loads that.
auto project_save(Project* self, const char* _dir, const bool is_backup, const bool show_notification, const bool async) -> int
Saves the project to a project file in the given dir.
auto project_autosave_cb(void* data) -> int
Autosave callback.
auto project_get_path(Project* self, ProjectPath path, bool backup) -> char*
Returns the requested project path as a newly allocated string.
auto project_init_selections(Project* self) -> COLD void
Initializes the selections in the project.
auto _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) -> bool
Compresses/decompress a project from a file/data to a file/data.
auto project_get_existing_yaml(Project* self, bool backup) -> char*
Returns the YAML representation of the saved project file.
auto project_clone(const Project* src) -> NONNULL Project*
Deep-clones the given project.
auto project_new(Zrythm* zrythm) -> COLD Project*
Creates an empty project object.
void project_free(Project* self)
Tears down the project.
auto settings_new(void) -> Settings*
Initializes settings.
void settings_reset_to_factory(int confirm, int exit_on_finish)
Resets settings to defaults.
void settings_print(int pretty_print)
Prints the current settings.
auto settings_strv_contains_str(GSettings* settings, const char* key, const char* val) -> NONNULL bool
Returns whether the "as" key contains the given string.
auto settings_append_to_strv(GSettings* settings, const char* key, const char* val, bool ignore_if_duplicate) -> NONNULL void
Appends the given string to a key of type "as".
void settings_free(Settings* self)
Frees settings.

Enum documentation

enum ProjectPath

Enumerators
PROJECT_PATH_PROJECT_FILE
PROJECT_PATH_BACKUPS
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.

PROJECT_PATH_EXPORTS
PROJECT_PATH_EXPORTS_STEMS
PROJECT_PATH_POOL

enum SelectionType

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

Enumerators
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.

Function documentation

COLD Project* project_create_default(Project* self, const char* prj_dir, bool headless, bool with_engine)

Creates a default project.

Parameters
self
prj_dir The directory of the project to create, including its title.
headless Create the project assuming we are running without a UI.
with_engine

This is only used internally or for generating projects from scripts.

COLD int project_load(const char* filename, const bool is_template)

If project has a filename set, it loads that.

Parameters
filename
is_template Load the project as a template and create a new project from it.
Returns 0 if successful, non-zero otherwise.

Otherwise it loads the default project.

int project_save(Project* self, const char* _dir, const bool is_backup, const bool show_notification, const bool async)

Saves the project to a project file in the given dir.

Parameters
self
_dir
is_backup 1 if this is a backup. Backups will be saved as <original filename>.bak<num>.
show_notification Show a notification in the UI that the project was saved.
async Save asynchronously in another thread.
Returns Non-zero if error.

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.

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

Returns the requested project path as a newly allocated string.

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

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.

Parameters
compress True to compress, false to decompress.
_dest out Pointer to a location to allocate memory.
_dest_size out Pointer to a location to store the size of the allocated memory.
dest_type
_src Input buffer or filepath.
_src_size Input buffer size, if not filepath.
src_type
error
Returns Whether successful.

char* project_get_existing_yaml(Project* self, bool backup)

Returns the YAML representation of the saved project file.

Parameters
self
backup Whether to use the project file from the most recent backup.

To be free'd with free().

NONNULL Project* project_clone(const Project* src)

Deep-clones the given project.

To be used during save on the main thread.

Settings* settings_new(void)

Initializes settings.

void settings_reset_to_factory(int confirm, int exit_on_finish)

Resets settings to defaults.

Parameters
confirm
exit_on_finish Exit with a code on finish.

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".

void settings_free(Settings* self)

Frees settings.