Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
Project Class Referencefinal

Contains all of the info that will be serialized into a project file. More...

#include <src/gui/backend/backend/project.h>

Inheritance diagram for Project:
Collaboration diagram for Project:

Public Types

enum class  SelectionType {
  Tracklist , Timeline , Insert , MidiFX ,
  Instrument , Modulator , Editor
}
 Selection type, used for controlling which part of the interface is selected, for copy-paste, displaying info in the inspector, etc. More...
 
enum class  CompressionFlag { PROJECT_COMPRESS_FILE = 0 , PROJECT_DECOMPRESS_FILE = 0 , PROJECT_COMPRESS_DATA = 1 , PROJECT_DECOMPRESS_DATA = 1 }
 Flag to pass to project_compress() and project_decompress(). More...
 
using QuantizeOptions = zrythm::gui::old_dsp::QuantizeOptions
 
using SnapGrid = zrythm::gui::SnapGrid
 
using TrackUuid = structure::tracks::TrackUuid
 
using PluginPtrVariant = gui::old_dsp::plugins::PluginPtrVariant
 
using PluginRegistry = gui::old_dsp::plugins::PluginRegistry
 

Public Member Functions

 Project (std::shared_ptr< juce::AudioDeviceManager > device_manager, QObject *parent=nullptr)
 
QString getTitle () const
 
void setTitle (const QString &title)
 
QString getDirectory () const
 
void setDirectory (const QString &directory)
 
structure::tracks::TracklistgetTracklist () const
 
TimelinegetTimeline () const
 
engine::session::TransportgetTransport () const
 
gui::backend::ToolgetTool () const
 
ClipEditorgetClipEditor () const
 
gui::actions::UndoManagergetUndoManager () const
 
structure::arrangement::ArrangerObjectFactorygetArrangerObjectFactory () const
 
PluginFactorygetPluginFactory () const
 
structure::tracks::TrackFactorygetTrackFactory () const
 
dsp::TempoMapWrappergetTempoMap () const
 
Q_SIGNAL void titleChanged (const QString &title)
 
Q_SIGNAL void directoryChanged (const QString &directory)
 
Q_SIGNAL void aboutToBeDeleted ()
 
fs::path get_path (ProjectPath path, bool backup)
 Returns the requested project path as a newly allocated string.
 
bool fix_audio_regions ()
 
void save (const fs::path &_dir, bool is_backup, bool show_notification, bool async)
 Saves the project to a project file in the given dir.
 
void make_project_dirs (bool is_backup)
 Creates the project directories.
 
std::string get_existing_uncompressed_text (bool backup)
 Returns the uncompressed text representation of the saved project file.
 
bool has_unsaved_changes () const
 
Q_INVOKABLE Projectclone (bool for_backup) const
 Deep-clones the given project.
 
std::optional< fs::path > get_newer_backup ()
 Returns the filepath of a backup (directory), if any, if it has a newer timestamp than main project file.
 
Q_INVOKABLE void activate ()
 Connects things up, exposes ports to the backend, calculates the graph and begins processing.
 
void get_all_ports (std::vector< Port * > &ports) const
 Gets all the ports in the project.
 
void add_default_tracks ()
 Adds the default undeletable tracks to the project.
 
bool is_audio_clip_in_use (const AudioClip &clip, bool check_undo_stack) const
 Returns whether the clip is used inside the project.
 
auto & get_track_registry () const
 
auto & get_plugin_registry () const
 
auto & get_port_registry () const
 
auto & get_arranger_object_registry () const
 
std::optional< PortPtrVariant > find_port_by_id (Port::Uuid id) const
 Finds the Port corresponding to the identifier.
 
std::optional< gui::old_dsp::plugins::PluginPtrVariant > find_plugin_by_id (gui::old_dsp::plugins::Plugin::Uuid id) const
 
std::optional< zrythm::structure::tracks::TrackPtrVariant > find_track_by_id (structure::tracks::Track::Uuid id) const
 
std::optional< zrythm::structure::arrangement::ArrangerObjectPtrVariant > find_arranger_object_by_id (structure::arrangement::ArrangerObject::Uuid id) const
 
const auto & get_tempo_map () const
 
void on_port_identifier_changed (const dsp::PortIdentifier &old_id, Port &updated_port)
 To be called when the port's identifier changes to update corresponding identifiers.
 

Static Public Member Functions

static Projectget_active_instance ()
 
static int autosave_cb (void *data)
 Autosave callback.
 
static void compress_or_decompress (bool compress, char **_dest, size_t *_dest_size, CompressionFlag dest_type, const QByteArray &src)
 Compresses/decompress a project from a file/data to a file/data.
 
static void compress (char **_dest, size_t *_dest_size, CompressionFlag dest_type, const QByteArray &src)
 
static void decompress (char **_dest, size_t *_dest_size, CompressionFlag dest_type, const QByteArray &src)
 

Data Fields

utils::Utf8String title_
 Project title.
 
utils::Utf8String datetime_str_
 Datetime string to add to the project file.
 
fs::path dir_
 Path to save the project in.
 
std::optional< fs::path > backup_dir_
 Backup dir to save the project during the current save call.
 
std::optional< gui::actions::UndoableActionPtrVariant > last_action_in_last_successful_autosave_
 
SteadyTimePoint last_successful_autosave_time_
 Last successful autosave timestamp.
 
std::optional< gui::actions::UndoableActionPtrVariant > last_saved_action_
 Used to check if the project has unsaved changes.
 
std::binary_semaphore save_sem_ { 1 }
 Semaphore used to block saving.
 
utils::Utf8String version_
 Zrythm version, for serialization.
 
Project::SelectionType last_selection_ = (SelectionType) 0
 The last thing selected in the GUI.
 
bool loaded_ = false
 If a project is currently loaded or not.
 
bool loading_from_backup_ = false
 Whether the current is currently being loaded from a backup file.
 
gui::backend::Tooltool_ {}
 Currently selected tool (select - normal, select - stretch, edit, delete, ramp, audition)
 
utils::QObjectUniquePtr< dsp::PortConnectionsManagerport_connections_manager_
 Must be free'd after engine.
 
std::unique_ptr< engine::device_io::AudioEngineaudio_engine_
 The audio backend.
 
engine::session::Transporttransport_
 Timeline metadata like BPM, time signature, etc.
 
double piano_roll_zoom_ = 0
 Zoom levels.
 
double timeline_zoom_ = 0
 
structure::arrangement::RegionLinkGroupManager region_link_group_manager_
 Manager for region link groups.
 
std::unique_ptr< QuantizeOptionsquantize_opts_editor_
 Quantize info for the piano roll.
 
std::unique_ptr< QuantizeOptionsquantize_opts_timeline_
 Quantize info for the timeline.
 
std::shared_ptr< SnapGridsnap_grid_editor_
 Snap/Grid info for the editor.
 
std::shared_ptr< SnapGridsnap_grid_timeline_
 Snap/Grid info for the timeline.
 
Timelinetimeline_ = nullptr
 Timeline widget backend.
 
ClipEditorclip_editor_
 Backend for the widget.
 
std::unique_ptr< engine::session::MidiMappingsmidi_mappings_
 MIDI bindings.
 
structure::tracks::Tracklisttracklist_ {}
 Tracklist.
 
gui::actions::UndoManagerundo_manager_ {}
 
structure::arrangement::ArrangerObjectFactoryarranger_object_factory_ {}
 
PluginFactoryplugin_factory_ {}
 
zrythm::structure::tracks::TrackFactorytrack_factory_ {}
 
int format_major_ = 0
 Used when deserializing projects.
 
int format_minor_ = 0
 
std::shared_ptr< juce::AudioDeviceManager > device_manager_
 

Static Public Attributes

static constexpr auto PROJECT_FILE = "project.zpj"sv
 
static constexpr auto PROJECT_BACKUPS_DIR = "backups"sv
 
static constexpr auto PROJECT_PLUGINS_DIR = "plugins"sv
 
static constexpr auto PROJECT_PLUGIN_STATES_DIR = "states"sv
 
static constexpr auto PROJECT_PLUGIN_EXT_COPIES_DIR = "ext_file_copies"sv
 
static constexpr auto PROJECT_PLUGIN_EXT_LINKS_DIR = "ext_file_links"sv
 
static constexpr auto PROJECT_EXPORTS_DIR = "exports"sv
 
static constexpr auto PROJECT_STEMS_DIR = "stems"sv
 
static constexpr auto PROJECT_POOL_DIR = "pool"sv
 
static constexpr auto PROJECT_FINISHED_FILE = "FINISHED"sv
 

Properties

QML_ELEMENT QString title
 
QString directory
 
structure::tracks::Tracklisttracklist
 
Timelinetimeline
 
engine::session::Transporttransport
 
gui::backend::Tooltool
 
ClipEditorclipEditor
 
gui::actions::UndoManagerundoManager
 
structure::arrangement::ArrangerObjectFactory *arrangerObjectFactory READ getArrangerObjectFactory
 
PluginFactorypluginFactory
 
structure::tracks::TrackFactorytrackFactory
 
dsp::TempoMapWrappertempoMap
 

Friends

void init_from (Project &obj, const Project &other, utils::ObjectCloneType clone_type)
 
void to_json (nlohmann::json &j, const Project &project)
 
void from_json (const nlohmann::json &j, Project &project)
 

Detailed Description

Contains all of the info that will be serialized into a project file.

Todo
Create a UserInterface struct and move things that are only relevant to the UI there.

A project (or song), contains all the project data as opposed to zrythm_app.h which manages global things like plugin descriptors and global settings.

Definition at line 72 of file project.h.

Member Typedef Documentation

◆ PluginPtrVariant

using Project::PluginPtrVariant = gui::old_dsp::plugins::PluginPtrVariant

Definition at line 103 of file project.h.

◆ PluginRegistry

◆ QuantizeOptions

◆ SnapGrid

Definition at line 101 of file project.h.

◆ TrackUuid

Definition at line 102 of file project.h.

Member Enumeration Documentation

◆ CompressionFlag

enum class Project::CompressionFlag
strong

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

Definition at line 155 of file project.h.

◆ SelectionType

enum class Project::SelectionType
strong

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

Enumerator
Tracklist 

Track selection in tracklist or mixer.

Timeline 

Timeline or pinned timeline.

Insert 

Insert selections in the mixer.

MidiFX 

MIDI FX selections in the mixer.

Instrument 

Instrument slot.

Modulator 

Modulator slot.

Editor 

Editor arranger.

Definition at line 128 of file project.h.

Member Function Documentation

◆ add_default_tracks()

void Project::add_default_tracks ( )

Adds the default undeletable tracks to the project.

To be called when creating new projects.

◆ autosave_cb()

static int Project::autosave_cb ( void * data)
static

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.

◆ clone()

Q_INVOKABLE Project * Project::clone ( bool for_backup) const

Deep-clones the given project.

To be used during save on the main thread.

Parameters
for_backupWhether the resulting project is for a backup.
Exceptions
ZrythmExceptionIf an error occurs.

◆ compress()

static void Project::compress ( char ** _dest,
size_t * _dest_size,
CompressionFlag dest_type,
const QByteArray & src )
inlinestatic

Definition at line 253 of file project.h.

◆ compress_or_decompress()

static void Project::compress_or_decompress ( bool compress,
char ** _dest,
size_t * _dest_size,
CompressionFlag dest_type,
const QByteArray & src )
static

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 bytes to compress/decompress.
Exceptions
ZrythmExceptionIf the compression/decompression fails.

◆ decompress()

static void Project::decompress ( char ** _dest,
size_t * _dest_size,
CompressionFlag dest_type,
const QByteArray & src )
inlinestatic

Definition at line 262 of file project.h.

◆ find_arranger_object_by_id()

std::optional< zrythm::structure::arrangement::ArrangerObjectPtrVariant > Project::find_arranger_object_by_id ( structure::arrangement::ArrangerObject::Uuid id) const
inline

Definition at line 370 of file project.h.

◆ find_plugin_by_id()

std::optional< gui::old_dsp::plugins::PluginPtrVariant > Project::find_plugin_by_id ( gui::old_dsp::plugins::Plugin::Uuid id) const
inline

Definition at line 358 of file project.h.

◆ find_port_by_id()

std::optional< PortPtrVariant > Project::find_port_by_id ( Port::Uuid id) const
inline

Finds the Port corresponding to the identifier.

Parameters
idThe PortIdentifier to use for searching.
Note
Ported from Port::find_from_identifier() in older code.

Definition at line 352 of file project.h.

◆ find_track_by_id()

std::optional< zrythm::structure::tracks::TrackPtrVariant > Project::find_track_by_id ( structure::tracks::Track::Uuid id) const
inline

Definition at line 364 of file project.h.

◆ fix_audio_regions()

bool Project::fix_audio_regions ( )
Returns
Whether positions were adjusted.

◆ get_all_ports()

void Project::get_all_ports ( std::vector< Port * > & ports) const

Gets all the ports in the project.

Parameters
portsArray to append to.

◆ get_arranger_object_registry()

auto & Project::get_arranger_object_registry ( ) const
inline

Definition at line 340 of file project.h.

◆ get_existing_uncompressed_text()

std::string Project::get_existing_uncompressed_text ( bool backup)

Returns the uncompressed text representation of the saved project file.

Parameters
backupWhether to use the project file from the most recent backup.
Exceptions
ZrythmExceptionIf an error occurs.

◆ get_newer_backup()

std::optional< fs::path > Project::get_newer_backup ( )

Returns the filepath of a backup (directory), if any, if it has a newer timestamp than main project file.

Returns nullopt if there were errors or no backup was found.

◆ get_path()

fs::path Project::get_path ( 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.

◆ get_plugin_registry()

auto & Project::get_plugin_registry ( ) const
inline

Definition at line 338 of file project.h.

◆ get_port_registry()

auto & Project::get_port_registry ( ) const
inline

Definition at line 339 of file project.h.

◆ get_tempo_map()

const auto & Project::get_tempo_map ( ) const
inline

Definition at line 376 of file project.h.

◆ get_track_registry()

auto & Project::get_track_registry ( ) const
inline

Definition at line 337 of file project.h.

◆ is_audio_clip_in_use()

bool Project::is_audio_clip_in_use ( const AudioClip & clip,
bool check_undo_stack ) const

Returns whether the clip is used inside the project.

Parameters
check_undo_stackIf true, this checks both project regions and the undo stack. If false, this only checks actual project regions only.

◆ make_project_dirs()

void Project::make_project_dirs ( bool is_backup)

Creates the project directories.

Parameters
is_backup
Exceptions
ZrythmExceptionIf the directories cannot be created.

◆ on_port_identifier_changed()

void Project::on_port_identifier_changed ( const dsp::PortIdentifier & old_id,
Port & updated_port )

To be called when the port's identifier changes to update corresponding identifiers.

Parameters
prev_idPrevious identifier to be used for searching.
trackThe track that owns this port.
update_automation_trackWhether to update the identifier in the corresponding automation track as well. This should be false when moving a plugin.

◆ save()

void Project::save ( const fs::path & _dir,
bool is_backup,
bool show_notification,
bool async )

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.
Exceptions
ZrythmExceptionIf the project cannot be saved.

Field Documentation

◆ arranger_object_factory_

structure::arrangement::ArrangerObjectFactory* Project::arranger_object_factory_ {}

Definition at line 617 of file project.h.

◆ audio_engine_

std::unique_ptr<engine::device_io::AudioEngine> Project::audio_engine_

The audio backend.

Definition at line 573 of file project.h.

◆ backup_dir_

std::optional<fs::path> Project::backup_dir_

Backup dir to save the project during the current save call.

For example, Project.dir /backups/myproject.bak3.

Definition at line 515 of file project.h.

◆ clip_editor_

ClipEditor* Project::clip_editor_

Backend for the widget.

Definition at line 603 of file project.h.

◆ datetime_str_

utils::Utf8String Project::datetime_str_

Datetime string to add to the project file.

Definition at line 505 of file project.h.

◆ device_manager_

std::shared_ptr<juce::AudioDeviceManager> Project::device_manager_

Definition at line 625 of file project.h.

◆ dir_

fs::path Project::dir_

Path to save the project in.

Definition at line 508 of file project.h.

◆ format_major_

int Project::format_major_ = 0

Used when deserializing projects.

Definition at line 622 of file project.h.

◆ format_minor_

int Project::format_minor_ = 0

Definition at line 623 of file project.h.

◆ last_action_in_last_successful_autosave_

std::optional<gui::actions::UndoableActionPtrVariant> Project::last_action_in_last_successful_autosave_

Definition at line 520 of file project.h.

◆ last_saved_action_

std::optional<gui::actions::UndoableActionPtrVariant> Project::last_saved_action_

Used to check if the project has unsaved changes.

Definition at line 526 of file project.h.

◆ last_selection_

Project::SelectionType Project::last_selection_ = (SelectionType) 0

The last thing selected in the GUI.

Used in inspector_widget_refresh.

Definition at line 539 of file project.h.

◆ last_successful_autosave_time_

SteadyTimePoint Project::last_successful_autosave_time_

Last successful autosave timestamp.

Definition at line 523 of file project.h.

◆ loaded_

bool Project::loaded_ = false

If a project is currently loaded or not.

This is useful so that we know if we need to tear down when loading a new project while another one is loaded.

Definition at line 547 of file project.h.

◆ loading_from_backup_

bool Project::loading_from_backup_ = false

Whether the current is currently being loaded from a backup file.

This is useful when instantiating plugins from state and should be set to false after the project is loaded.

Definition at line 555 of file project.h.

◆ midi_mappings_

std::unique_ptr<engine::session::MidiMappings> Project::midi_mappings_

MIDI bindings.

Definition at line 606 of file project.h.

◆ piano_roll_zoom_

double Project::piano_roll_zoom_ = 0

Zoom levels.

TODO & move to clip_editor

Definition at line 581 of file project.h.

◆ plugin_factory_

PluginFactory* Project::plugin_factory_ {}

Definition at line 618 of file project.h.

◆ port_connections_manager_

utils::QObjectUniquePtr<dsp::PortConnectionsManager> Project::port_connections_manager_

Must be free'd after engine.

Definition at line 568 of file project.h.

◆ PROJECT_BACKUPS_DIR

auto Project::PROJECT_BACKUPS_DIR = "backups"sv
staticconstexpr

Definition at line 107 of file project.h.

◆ PROJECT_EXPORTS_DIR

auto Project::PROJECT_EXPORTS_DIR = "exports"sv
staticconstexpr

Definition at line 112 of file project.h.

◆ PROJECT_FILE

auto Project::PROJECT_FILE = "project.zpj"sv
staticconstexpr

Definition at line 106 of file project.h.

◆ PROJECT_FINISHED_FILE

auto Project::PROJECT_FINISHED_FILE = "FINISHED"sv
staticconstexpr

Definition at line 115 of file project.h.

◆ PROJECT_PLUGIN_EXT_COPIES_DIR

auto Project::PROJECT_PLUGIN_EXT_COPIES_DIR = "ext_file_copies"sv
staticconstexpr

Definition at line 110 of file project.h.

◆ PROJECT_PLUGIN_EXT_LINKS_DIR

auto Project::PROJECT_PLUGIN_EXT_LINKS_DIR = "ext_file_links"sv
staticconstexpr

Definition at line 111 of file project.h.

◆ PROJECT_PLUGIN_STATES_DIR

auto Project::PROJECT_PLUGIN_STATES_DIR = "states"sv
staticconstexpr

Definition at line 109 of file project.h.

◆ PROJECT_PLUGINS_DIR

auto Project::PROJECT_PLUGINS_DIR = "plugins"sv
staticconstexpr

Definition at line 108 of file project.h.

◆ PROJECT_POOL_DIR

auto Project::PROJECT_POOL_DIR = "pool"sv
staticconstexpr

Definition at line 114 of file project.h.

◆ PROJECT_STEMS_DIR

auto Project::PROJECT_STEMS_DIR = "stems"sv
staticconstexpr

Definition at line 113 of file project.h.

◆ quantize_opts_editor_

std::unique_ptr<QuantizeOptions> Project::quantize_opts_editor_

Quantize info for the piano roll.

Definition at line 588 of file project.h.

◆ quantize_opts_timeline_

std::unique_ptr<QuantizeOptions> Project::quantize_opts_timeline_

Quantize info for the timeline.

Definition at line 591 of file project.h.

◆ region_link_group_manager_

structure::arrangement::RegionLinkGroupManager Project::region_link_group_manager_

Manager for region link groups.

Definition at line 585 of file project.h.

◆ save_sem_

std::binary_semaphore Project::save_sem_ { 1 }

Semaphore used to block saving.

Definition at line 529 of file project.h.

◆ snap_grid_editor_

std::shared_ptr<SnapGrid> Project::snap_grid_editor_

Snap/Grid info for the editor.

Definition at line 594 of file project.h.

◆ snap_grid_timeline_

std::shared_ptr<SnapGrid> Project::snap_grid_timeline_

Snap/Grid info for the timeline.

Definition at line 597 of file project.h.

◆ timeline_

Timeline* Project::timeline_ = nullptr

Timeline widget backend.

Definition at line 600 of file project.h.

◆ timeline_zoom_

double Project::timeline_zoom_ = 0

Definition at line 582 of file project.h.

◆ title_

utils::Utf8String Project::title_

Project title.

Definition at line 502 of file project.h.

◆ tool_

gui::backend::Tool* Project::tool_ {}

Currently selected tool (select - normal, select - stretch, edit, delete, ramp, audition)

Definition at line 561 of file project.h.

◆ track_factory_

zrythm::structure::tracks::TrackFactory* Project::track_factory_ {}

Definition at line 619 of file project.h.

◆ tracklist_

structure::tracks::Tracklist* Project::tracklist_ {}

Tracklist.

Must be free'd before engine and port connection manager.

Definition at line 613 of file project.h.

◆ transport_

engine::session::Transport* Project::transport_

Timeline metadata like BPM, time signature, etc.

Definition at line 578 of file project.h.

◆ undo_manager_

gui::actions::UndoManager* Project::undo_manager_ {}

Definition at line 615 of file project.h.

◆ version_

utils::Utf8String Project::version_

Zrythm version, for serialization.

Definition at line 532 of file project.h.

Property Documentation

◆ clipEditor

ClipEditor * Project::clipEditor
read

Definition at line 87 of file project.h.

◆ directory

QString Project::directory
readwrite

Definition at line 78 of file project.h.

◆ getArrangerObjectFactory

structure::arrangement::ArrangerObjectFactory * arrangerObjectFactory READ Project::getArrangerObjectFactory

Definition at line 90 of file project.h.

◆ pluginFactory

PluginFactory * Project::pluginFactory
read

Definition at line 93 of file project.h.

◆ tempoMap

dsp::TempoMapWrapper * Project::tempoMap
read

Definition at line 97 of file project.h.

◆ timeline

Timeline * Project::timeline
read

Definition at line 83 of file project.h.

◆ title

QML_ELEMENT QString Project::title
readwrite

Definition at line 76 of file project.h.

◆ tool

gui::backend::Tool * Project::tool
read

Definition at line 86 of file project.h.

◆ trackFactory

structure::tracks::TrackFactory * Project::trackFactory
read

Definition at line 94 of file project.h.

◆ tracklist

structure::tracks::Tracklist * Project::tracklist
read

Definition at line 81 of file project.h.

◆ transport

engine::session::Transport * Project::transport
read

Definition at line 84 of file project.h.

◆ undoManager

gui::actions::UndoManager * Project::undoManager
read

Definition at line 88 of file project.h.


The documentation for this class was generated from the following file: