Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
Contains all of the info that will be serialized into a project file. More...
#include <src/gui/backend/backend/project.h>
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::Tracklist * | getTracklist () const |
Timeline * | getTimeline () const |
engine::session::Transport * | getTransport () const |
gui::backend::Tool * | getTool () const |
ClipEditor * | getClipEditor () const |
gui::actions::UndoManager * | getUndoManager () const |
structure::arrangement::ArrangerObjectFactory * | getArrangerObjectFactory () const |
PluginFactory * | getPluginFactory () const |
structure::tracks::TrackFactory * | getTrackFactory () const |
dsp::TempoMapWrapper * | getTempoMap () 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 Project * | clone (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 Project * | get_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::Tool * | tool_ {} |
Currently selected tool (select - normal, select - stretch, edit, delete, ramp, audition) | |
utils::QObjectUniquePtr< dsp::PortConnectionsManager > | port_connections_manager_ |
Must be free'd after engine. | |
std::unique_ptr< engine::device_io::AudioEngine > | audio_engine_ |
The audio backend. | |
engine::session::Transport * | transport_ |
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< QuantizeOptions > | quantize_opts_editor_ |
Quantize info for the piano roll. | |
std::unique_ptr< QuantizeOptions > | quantize_opts_timeline_ |
Quantize info for the timeline. | |
std::shared_ptr< SnapGrid > | snap_grid_editor_ |
Snap/Grid info for the editor. | |
std::shared_ptr< SnapGrid > | snap_grid_timeline_ |
Snap/Grid info for the timeline. | |
Timeline * | timeline_ = nullptr |
Timeline widget backend. | |
ClipEditor * | clip_editor_ |
Backend for the widget. | |
std::unique_ptr< engine::session::MidiMappings > | midi_mappings_ |
MIDI bindings. | |
structure::tracks::Tracklist * | tracklist_ {} |
Tracklist. | |
gui::actions::UndoManager * | undo_manager_ {} |
structure::arrangement::ArrangerObjectFactory * | arranger_object_factory_ {} |
PluginFactory * | plugin_factory_ {} |
zrythm::structure::tracks::TrackFactory * | track_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::Tracklist * | tracklist |
Timeline * | timeline |
engine::session::Transport * | transport |
gui::backend::Tool * | tool |
ClipEditor * | clipEditor |
gui::actions::UndoManager * | undoManager |
structure::arrangement::ArrangerObjectFactory *arrangerObjectFactory READ | getArrangerObjectFactory |
PluginFactory * | pluginFactory |
structure::tracks::TrackFactory * | trackFactory |
dsp::TempoMapWrapper * | tempoMap |
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) |
Contains all of the info that will be serialized into a project file.
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.
using Project::PluginPtrVariant = gui::old_dsp::plugins::PluginPtrVariant |
|
strong |
|
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. |
void Project::add_default_tracks | ( | ) |
Adds the default undeletable tracks to the project.
To be called when creating new projects.
|
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.
Q_INVOKABLE Project * Project::clone | ( | bool | for_backup | ) | const |
Deep-clones the given project.
To be used during save on the main thread.
for_backup | Whether the resulting project is for a backup. |
ZrythmException | If an error occurs. |
|
inlinestatic |
|
static |
Compresses/decompress a project from a file/data to a file/data.
compress | True to compress, false to decompress. | |
[out] | _dest | Pointer to a location to allocate memory. |
[out] | _dest_size | Pointer to a location to store the size of the allocated memory. |
src | Input bytes to compress/decompress. |
ZrythmException | If the compression/decompression fails. |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
bool Project::fix_audio_regions | ( | ) |
void Project::get_all_ports | ( | std::vector< Port * > & | ports | ) | const |
Gets all the ports in the project.
ports | Array to append to. |
|
inline |
std::string Project::get_existing_uncompressed_text | ( | bool | backup | ) |
Returns the uncompressed text representation of the saved project file.
backup | Whether to use the project file from the most recent backup. |
ZrythmException | If an error occurs. |
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.
fs::path Project::get_path | ( | ProjectPath | path, |
bool | backup ) |
Returns the requested project path as a newly allocated string.
backup | Whether to get the path for the current backup instead of the main project. |
bool Project::is_audio_clip_in_use | ( | const AudioClip & | clip, |
bool | check_undo_stack ) const |
Returns whether the clip is used inside the project.
check_undo_stack | If true, this checks both project regions and the undo stack. If false, this only checks actual project regions only. |
void Project::make_project_dirs | ( | bool | is_backup | ) |
Creates the project directories.
is_backup |
ZrythmException | If the directories cannot be created. |
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.
prev_id | Previous identifier to be used for searching. |
track | The track that owns this port. |
update_automation_track | Whether to update the identifier in the corresponding automation track as well. This should be false when moving a plugin. |
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.
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. |
ZrythmException | If the project cannot be saved. |
structure::arrangement::ArrangerObjectFactory* Project::arranger_object_factory_ {} |
std::unique_ptr<engine::device_io::AudioEngine> Project::audio_engine_ |
std::optional<fs::path> Project::backup_dir_ |
ClipEditor* Project::clip_editor_ |
utils::Utf8String Project::datetime_str_ |
std::shared_ptr<juce::AudioDeviceManager> Project::device_manager_ |
int Project::format_major_ = 0 |
std::optional<gui::actions::UndoableActionPtrVariant> Project::last_action_in_last_successful_autosave_ |
std::optional<gui::actions::UndoableActionPtrVariant> Project::last_saved_action_ |
Project::SelectionType Project::last_selection_ = (SelectionType) 0 |
SteadyTimePoint Project::last_successful_autosave_time_ |
bool Project::loaded_ = false |
bool Project::loading_from_backup_ = false |
std::unique_ptr<engine::session::MidiMappings> Project::midi_mappings_ |
double Project::piano_roll_zoom_ = 0 |
PluginFactory* Project::plugin_factory_ {} |
utils::QObjectUniquePtr<dsp::PortConnectionsManager> Project::port_connections_manager_ |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
std::unique_ptr<QuantizeOptions> Project::quantize_opts_editor_ |
std::unique_ptr<QuantizeOptions> Project::quantize_opts_timeline_ |
structure::arrangement::RegionLinkGroupManager Project::region_link_group_manager_ |
std::binary_semaphore Project::save_sem_ { 1 } |
std::shared_ptr<SnapGrid> Project::snap_grid_editor_ |
std::shared_ptr<SnapGrid> Project::snap_grid_timeline_ |
Timeline* Project::timeline_ = nullptr |
utils::Utf8String Project::title_ |
gui::backend::Tool* Project::tool_ {} |
zrythm::structure::tracks::TrackFactory* Project::track_factory_ {} |
structure::tracks::Tracklist* Project::tracklist_ {} |
engine::session::Transport* Project::transport_ |
gui::actions::UndoManager* Project::undo_manager_ {} |
utils::Utf8String Project::version_ |
|
read |
structure::arrangement::ArrangerObjectFactory * arrangerObjectFactory READ Project::getArrangerObjectFactory |
|
read |
|
read |
|
read |
|
read |
|
read |
|
read |
|
read |