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 <memory>
7
8#include "engine/session/recording_manager.h"
9#include "gui/backend/backend/settings/chord_preset_pack_manager.h"
11#include "gui/backend/plugin_manager.h"
12#include "utils/dsp_context.h"
13#include "utils/monotonic_time_provider.h"
14#include "utils/networking.h"
15#include "utils/symap.h"
16#include "utils/version.h"
17
18#include "juce_wrapper.h"
19
25
26#define MAX_RECENT_PROJECTS 20
27#define DEBUGGING (Q_UNLIKELY (gZrythm && gZrythm->debug_))
28#define ZRYTHM_BENCHMARKING (gZrythm && gZrythm->benchmarking_)
29#define ZRYTHM_GENERATING_PROJECT (gZrythm->generating_project_)
30#define ZRYTHM_HAVE_UI (gZrythm && gZrythm->have_ui_)
31#define ZRYTHM_BREAK_ON_ERROR (gZrythm && gZrythm->break_on_error_)
32
33#define ZRYTHM_USE_OPTIMIZED_DSP (Q_LIKELY (gZrythm->use_optimized_dsp_))
34
40class Zrythm final : public QObject, public utils::QElapsedTimeProvider
41{
42 Q_OBJECT
43 QML_ELEMENT
44 Q_PROPERTY (QString version READ getVersion CONSTANT FINAL)
45 QML_UNCREATABLE ("")
46public:
47 ~Zrythm () override;
48
57 void
58 pre_init (std::optional<fs::path> exe_path, bool have_ui, bool optimized_dsp);
59
60 void init ();
61
62 QString getVersion () const { return get_version (false).to_qstring (); }
63
69 static utils::Utf8String get_version (bool with_v);
70
75
82 static bool is_release (bool official);
83
90 networking::URL::GetContentsAsyncCallback callback);
91
96 static bool is_latest_release (const char * remote_latest_release);
97
105 static void
106 get_version_with_capabilities (char * buf, bool include_system_info);
107
112
119
120private:
121 Zrythm ();
122
123public:
125 fs::path exe_path_;
126
130 std::unique_ptr<Settings> settings_;
131
134 bool opening_template_ = false;
135
137 bool creating_project_ = false;
138
141
148
153
157 bool debug_ = false;
158
160 bool break_on_error_ = false;
161
165
168 bool have_ui_ = false;
169
171 bool use_optimized_dsp_ = false;
172
175
181 bool open_newer_backup_ = false;
182
192
195
197 std::unique_ptr<ChordPresetPackManager> chord_preset_pack_manager_;
198
201
205 std::unique_ptr<DspContextRAII> lsp_dsp_context_;
206
210 bool benchmarking_ = false;
211
212 JUCE_DECLARE_SINGLETON_SINGLETHREADED (Zrythm, false)
213
214 JUCE_HEAVYWEIGHT_LEAK_DETECTOR (Zrythm)
215};
216
217#define gZrythm (Zrythm::getInstanceWithoutCreating ())
218
A string interner (Symbol Map).
Definition symap.h:46
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:125
fs::path open_filename_
Filename to open passed through the command line.
Definition zrythm.h:147
bool have_ui_
1 if Zrythm has a UI, 0 if headless (eg, when unit-testing).
Definition zrythm.h:168
bool generating_project_
Whether this is a dummy instance used when generating projects.
Definition zrythm.h:164
bool break_on_error_
Whether to abort() on an error log message.
Definition zrythm.h:160
bool creating_project_
Whether creating a new project, either from a template or blank.
Definition zrythm.h:137
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:130
bool debug_
In debug mode or not (determined by GSetting).
Definition zrythm.h:157
bool use_optimized_dsp_
Whether to use optimized DSP when available.
Definition zrythm.h:171
bool benchmarking_
Whether currently running under the benchmarker.
Definition zrythm.h:210
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:191
bool opening_template_
Whether the open file is a template to be used to create a new project from.
Definition zrythm.h:134
Symap symap_
String interner for internal things.
Definition zrythm.h:152
bool open_newer_backup_
Whether to open a newer backup if found.
Definition zrythm.h:181
fs::path create_project_path_
Path to create a project in, including its title.
Definition zrythm.h:140
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:200
ProcessId pipewire_pid_
Process ID for pipewire (used in tests).
Definition zrythm.h:194
static utils::Version get_app_version()
Returns the application version as a Version struct.
std::unique_ptr< ChordPresetPackManager > chord_preset_pack_manager_
Chord preset pack manager.
Definition zrythm.h:197
int undo_stack_len_
Undo stack length, used during tests.
Definition zrythm.h:174
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:205
static bool is_release(bool official)
Returns whether the current Zrythm version is a release version.
Handles the recording logic for the application.
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38
qint64 ProcessId
GPid equivalent.
Definition types.h:87
Zrythm settings.
Represents a semantic version with major, minor, and optional patch.
Definition version.h:29
API for Symap, a basic symbol map (string interner).