Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm.h
1// SPDX-FileCopyrightText: © 2019-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "zrythm-config.h"
7
8#include <memory>
9
10#include "engine/session/recording_manager.h"
11#include "gui/backend/backend/file_manager.h"
12#include "gui/backend/backend/project.h"
13#include "gui/backend/backend/settings/chord_preset_pack_manager.h"
15#include "gui/backend/plugin_manager.h"
16#include "utils/dsp_context.h"
17#include "utils/monotonic_time_provider.h"
18#include "utils/networking.h"
19#include "utils/symap.h"
20
21#include "juce_wrapper.h"
22
28
29#define MAX_RECENT_PROJECTS 20
30#define DEBUGGING (Q_UNLIKELY (gZrythm && gZrythm->debug_))
31#define ZRYTHM_BENCHMARKING (gZrythm && gZrythm->benchmarking_)
32#define ZRYTHM_GENERATING_PROJECT (gZrythm->generating_project_)
33#define ZRYTHM_HAVE_UI (gZrythm && gZrythm->have_ui_)
34#define ZRYTHM_BREAK_ON_ERROR (gZrythm && gZrythm->break_on_error_)
35
36#define ZRYTHM_USE_OPTIMIZED_DSP (Q_LIKELY (gZrythm->use_optimized_dsp_))
37
43class Zrythm final : public QObject, public utils::QElapsedTimeProvider
44{
45 Q_OBJECT
46 QML_ELEMENT
47 Q_PROPERTY (
49 getPluginManager CONSTANT FINAL)
50 Q_PROPERTY (QString version READ getVersion CONSTANT FINAL)
51 QML_UNCREATABLE ("")
52public:
53 ~Zrythm () override;
54
63 void
64 pre_init (std::optional<fs::path> exe_path, bool have_ui, bool optimized_dsp);
65
66 void init ();
67
68 zrythm::gui::old_dsp::plugins::PluginManager * getPluginManager () const
69 {
70 return plugin_manager_.get ();
71 }
72
73 QString getVersion () const { return get_version (false).to_qstring (); }
74
80 static utils::Utf8String get_version (bool with_v);
81
88 static bool is_release (bool official);
89
96 networking::URL::GetContentsAsyncCallback callback);
97
102 static bool is_latest_release (const char * remote_latest_release);
103
111 static void
112 get_version_with_capabilities (char * buf, bool include_system_info);
113
118
125
126 FileManager &get_file_manager () { return file_manager_; }
127
128private:
129 Zrythm ();
130
131public:
133 fs::path exe_path_;
134
138 std::unique_ptr<Settings> settings_;
139
142 bool opening_template_ = false;
145 bool creating_project_ = false;
148 fs::path create_project_path_;
149
155 fs::path open_filename_;
159
164
168 bool debug_ = false;
171 bool break_on_error_ = false;
172
175 bool generating_project_ = false;
176
179 bool have_ui_ = false;
182 bool use_optimized_dsp_ = false;
185 int undo_stack_len_ = 0;
186
192 bool open_newer_backup_ = false;
193
202 bool use_pipewire_in_tests_ = false;
208 std::unique_ptr<ChordPresetPackManager> chord_preset_pack_manager_;
209
210 // std::unique_ptr<EventManager> event_manager_;
211
215 std::unique_ptr<zrythm::gui::old_dsp::plugins::PluginManager> plugin_manager_;
219
229 std::unique_ptr<Project> project_;
230
234 std::unique_ptr<DspContextRAII> lsp_dsp_context_;
235
239 bool benchmarking_ = false;
240
241 JUCE_DECLARE_SINGLETON_SINGLETHREADED (Zrythm, false)
242
243 JUCE_HEAVYWEIGHT_LEAK_DETECTOR (Zrythm)
244};
245
246#define gZrythm (Zrythm::getInstanceWithoutCreating ())
247
Manages the file browser functionality, including loading files, setting the current selection,...
A string interner (Symbol Map).
Definition symap.h:46
To be used throughout the program.
Definition zrythm.h:44
void init_user_dirs_and_files()
Initializes/creates the default dirs/files in the user directory.
fs::path exe_path_
argv[0].
Definition zrythm.h:131
fs::path open_filename_
Filename to open passed through the command line.
Definition zrythm.h:153
FileManager file_manager_
File manager.
Definition zrythm.h:156
bool have_ui_
1 if Zrythm has a UI, 0 if headless (eg, when unit-testing).
Definition zrythm.h:177
bool generating_project_
Whether this is a dummy instance used when generating projects.
Definition zrythm.h:173
std::unique_ptr< Project > project_
Project data.
Definition zrythm.h:227
bool break_on_error_
Whether to abort() on an error log message.
Definition zrythm.h:169
bool creating_project_
Whether creating a new project, either from a template or blank.
Definition zrythm.h:143
void pre_init(std::optional< fs::path > exe_path, bool have_ui, bool optimized_dsp)
Called before init().
static void get_version_with_capabilities(char *buf, bool include_system_info)
Returns the version and the capabilities.
std::unique_ptr< Settings > settings_
Application settings.
Definition zrythm.h:136
bool debug_
In debug mode or not (determined by GSetting).
Definition zrythm.h:166
bool use_optimized_dsp_
Whether to use optimized DSP when available.
Definition zrythm.h:180
bool benchmarking_
Whether currently running under the benchmarker.
Definition zrythm.h:237
static void fetch_latest_release_ver_async(networking::URL::GetContentsAsyncCallback callback)
bool use_pipewire_in_tests_
Whether to use pipewire in tests.
Definition zrythm.h:200
bool opening_template_
Whether the open file is a template to be used to create a new project from.
Definition zrythm.h:140
Symap symap_
String interner for internal things.
Definition zrythm.h:161
bool open_newer_backup_
Whether to open a newer backup if found.
Definition zrythm.h:190
fs::path create_project_path_
Path to create a project in, including its title.
Definition zrythm.h:146
std::unique_ptr< zrythm::gui::old_dsp::plugins::PluginManager > plugin_manager_
Manages plugins (loading, instantiating, etc.).
Definition zrythm.h:213
static utils::Utf8String get_system_info()
Returns system info (mainly used for bug reports).
static bool is_latest_release(const char *remote_latest_release)
Returns whether the given release string is the latest release.
engine::session::RecordingManager * recording_manager_
Recording manager.
Definition zrythm.h:216
ProcessId pipewire_pid_
Process ID for pipewire (used in tests).
Definition zrythm.h:203
std::unique_ptr< ChordPresetPackManager > chord_preset_pack_manager_
Chord preset pack manager.
Definition zrythm.h:206
int undo_stack_len_
Undo stack length, used during tests.
Definition zrythm.h:183
static utils::Utf8String get_version(bool with_v)
Returns the version string.
std::unique_ptr< DspContextRAII > lsp_dsp_context_
LSP DSP context for the main thread.
Definition zrythm.h:232
static bool is_release(bool official)
Returns whether the current Zrythm version is a release version.
Handles the recording logic for the application.
The PluginManager is responsible for scanning and keeping track of available Plugin's.
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38
qint64 ProcessId
GPid equivalent.
Definition types.h:87
Zrythm settings.
API for Symap, a basic symbol map (string interner).