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
17#include "juce_wrapper.h"
18
24
25#define MAX_RECENT_PROJECTS 20
26#define DEBUGGING (Q_UNLIKELY (gZrythm && gZrythm->debug_))
27#define ZRYTHM_BENCHMARKING (gZrythm && gZrythm->benchmarking_)
28#define ZRYTHM_GENERATING_PROJECT (gZrythm->generating_project_)
29#define ZRYTHM_HAVE_UI (gZrythm && gZrythm->have_ui_)
30#define ZRYTHM_BREAK_ON_ERROR (gZrythm && gZrythm->break_on_error_)
31
32#define ZRYTHM_USE_OPTIMIZED_DSP (Q_LIKELY (gZrythm->use_optimized_dsp_))
33
39class Zrythm final : public QObject, public utils::QElapsedTimeProvider
40{
41 Q_OBJECT
42 QML_ELEMENT
43 Q_PROPERTY (QString version READ getVersion CONSTANT FINAL)
44 QML_UNCREATABLE ("")
45public:
46 ~Zrythm () override;
47
56 void
57 pre_init (std::optional<fs::path> exe_path, bool have_ui, bool optimized_dsp);
58
59 void init ();
60
61 QString getVersion () const { return get_version (false).to_qstring (); }
62
68 static utils::Utf8String get_version (bool with_v);
69
76 static bool is_release (bool official);
77
84 networking::URL::GetContentsAsyncCallback callback);
85
90 static bool is_latest_release (const char * remote_latest_release);
91
99 static void
100 get_version_with_capabilities (char * buf, bool include_system_info);
101
106
113
114private:
115 Zrythm ();
116
117public:
119 fs::path exe_path_;
120
124 std::unique_ptr<Settings> settings_;
125
128 bool opening_template_ = false;
129
131 bool creating_project_ = false;
132
135
142
147
151 bool debug_ = false;
152
154 bool break_on_error_ = false;
155
159
162 bool have_ui_ = false;
163
165 bool use_optimized_dsp_ = false;
166
169
175 bool open_newer_backup_ = false;
176
186
189
191 std::unique_ptr<ChordPresetPackManager> chord_preset_pack_manager_;
192
195
199 std::unique_ptr<DspContextRAII> lsp_dsp_context_;
200
204 bool benchmarking_ = false;
205
206 JUCE_DECLARE_SINGLETON_SINGLETHREADED (Zrythm, false)
207
208 JUCE_HEAVYWEIGHT_LEAK_DETECTOR (Zrythm)
209};
210
211#define gZrythm (Zrythm::getInstanceWithoutCreating ())
212
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:119
fs::path open_filename_
Filename to open passed through the command line.
Definition zrythm.h:141
bool have_ui_
1 if Zrythm has a UI, 0 if headless (eg, when unit-testing).
Definition zrythm.h:162
bool generating_project_
Whether this is a dummy instance used when generating projects.
Definition zrythm.h:158
bool break_on_error_
Whether to abort() on an error log message.
Definition zrythm.h:154
bool creating_project_
Whether creating a new project, either from a template or blank.
Definition zrythm.h:131
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:124
bool debug_
In debug mode or not (determined by GSetting).
Definition zrythm.h:151
bool use_optimized_dsp_
Whether to use optimized DSP when available.
Definition zrythm.h:165
bool benchmarking_
Whether currently running under the benchmarker.
Definition zrythm.h:204
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:185
bool opening_template_
Whether the open file is a template to be used to create a new project from.
Definition zrythm.h:128
Symap symap_
String interner for internal things.
Definition zrythm.h:146
bool open_newer_backup_
Whether to open a newer backup if found.
Definition zrythm.h:175
fs::path create_project_path_
Path to create a project in, including its title.
Definition zrythm.h:134
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:194
ProcessId pipewire_pid_
Process ID for pipewire (used in tests).
Definition zrythm.h:188
std::unique_ptr< ChordPresetPackManager > chord_preset_pack_manager_
Chord preset pack manager.
Definition zrythm.h:191
int undo_stack_len_
Undo stack length, used during tests.
Definition zrythm.h:168
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:199
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.
API for Symap, a basic symbol map (string interner).