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 "utils/monotonic_time_provider.h"
9#include "utils/networking.h"
10#include "utils/symap.h"
11#include "utils/types.h"
12#include "utils/version.h"
13
14#include <QtQmlIntegration/QtQmlIntegration>
15
16#include <juce_core/juce_core.h>
17
19class DspContextRAII;
20class Settings;
21
22namespace zrythm
23{
24
30
31#define MAX_RECENT_PROJECTS 20
32#define DEBUGGING (Q_UNLIKELY (gZrythm && gZrythm->debug_))
33#define ZRYTHM_BENCHMARKING (gZrythm && gZrythm->benchmarking_)
34#define ZRYTHM_GENERATING_PROJECT (gZrythm->generating_project_)
35#define ZRYTHM_HAVE_UI (gZrythm && gZrythm->have_ui_)
36#define ZRYTHM_BREAK_ON_ERROR (gZrythm && gZrythm->break_on_error_)
37
38#define ZRYTHM_USE_OPTIMIZED_DSP (Q_LIKELY (gZrythm->use_optimized_dsp_))
39
45class Zrythm final : public QObject, public utils::QElapsedTimeProvider
46{
47 Q_OBJECT
48 QML_ELEMENT
49 Q_PROPERTY (QString version READ getVersion CONSTANT FINAL)
50 QML_UNCREATABLE ("")
51public:
52 ~Zrythm () override;
53
62 void pre_init (
63 std::optional<std::filesystem::path> exe_path,
64 bool have_ui,
65 bool optimized_dsp);
66
67 void init ();
68
69 QString getVersion () const { return get_version (false).to_qstring (); }
70
76 static utils::Utf8String get_version (bool with_v);
77
82
89 static bool is_release (bool official);
90
97 networking::URL::GetContentsAsyncCallback callback);
98
103 static bool is_latest_release (const char * remote_latest_release);
104
112 static void
113 get_version_with_capabilities (char * buf, bool include_system_info);
114
119
126
127private:
128 Zrythm ();
129
130public:
132 std::filesystem::path exe_path_;
133
137 std::unique_ptr<Settings> settings_;
138
141 bool opening_template_ = false;
142
144 bool creating_project_ = false;
145
147 std::filesystem::path create_project_path_;
148
154 std::filesystem::path open_filename_;
155
160
164 bool debug_ = false;
165
167 bool break_on_error_ = false;
168
172
175 bool have_ui_ = false;
176
178 bool use_optimized_dsp_ = false;
179
182
188 bool open_newer_backup_ = false;
189
199
202
204 std::unique_ptr<ChordPresetPackManager> chord_preset_pack_manager_;
205
209 std::unique_ptr<DspContextRAII> lsp_dsp_context_;
210
214 bool benchmarking_ = false;
215
216 JUCE_DECLARE_SINGLETON_SINGLETHREADED (Zrythm, false)
217
218 JUCE_HEAVYWEIGHT_LEAK_DETECTOR (Zrythm)
219};
220
221} // namespace zrythm
222
223#define gZrythm (::zrythm::Zrythm::getInstanceWithoutCreating ())
224
Chord preset pack manager.
RAII class for managing a DSP context (disabling denormals, etc.).
Definition dsp_context.h:15
A string interner (Symbol Map).
Definition symap.h:46
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:37
static bool is_latest_release(const char *remote_latest_release)
Returns whether the given release string is the latest release.
std::unique_ptr< DspContextRAII > lsp_dsp_context_
LSP DSP context for the main thread.
Definition zrythm.h:209
static bool is_release(bool official)
Returns whether the current Zrythm version is a release version.
void init_user_dirs_and_files()
Initializes/creates the default dirs/files in the user directory.
bool use_optimized_dsp_
Whether to use optimized DSP when available.
Definition zrythm.h:178
bool debug_
In debug mode or not (determined by GSetting).
Definition zrythm.h:164
bool use_pipewire_in_tests_
Whether to use pipewire in tests.
Definition zrythm.h:198
bool open_newer_backup_
Whether to open a newer backup if found.
Definition zrythm.h:188
ProcessId pipewire_pid_
Process ID for pipewire (used in tests).
Definition zrythm.h:201
bool break_on_error_
Whether to abort() on an error log message.
Definition zrythm.h:167
int undo_stack_len_
Undo stack length, used during tests.
Definition zrythm.h:181
bool creating_project_
Whether creating a new project, either from a template or blank.
Definition zrythm.h:144
std::unique_ptr< Settings > settings_
Application settings.
Definition zrythm.h:137
static void fetch_latest_release_ver_async(networking::URL::GetContentsAsyncCallback callback)
std::filesystem::path open_filename_
Filename to open passed through the command line.
Definition zrythm.h:154
static void get_version_with_capabilities(char *buf, bool include_system_info)
Returns the version and the capabilities.
Symap symap_
String interner for internal things.
Definition zrythm.h:159
bool benchmarking_
Whether currently running under the benchmarker.
Definition zrythm.h:214
static utils::Utf8String get_system_info()
Returns system info (mainly used for bug reports).
void pre_init(std::optional< std::filesystem::path > exe_path, bool have_ui, bool optimized_dsp)
Called before init().
std::unique_ptr< ChordPresetPackManager > chord_preset_pack_manager_
Chord preset pack manager.
Definition zrythm.h:204
static utils::Utf8String get_version(bool with_v)
Returns the version string.
static utils::Version get_app_version()
Returns the application version as a Version struct.
bool generating_project_
Whether this is a dummy instance used when generating projects.
Definition zrythm.h:171
std::filesystem::path exe_path_
argv[0].
Definition zrythm.h:132
std::filesystem::path create_project_path_
Path to create a project in, including its title.
Definition zrythm.h:147
bool opening_template_
Whether the open file is a template to be used to create a new project from.
Definition zrythm.h:141
bool have_ui_
1 if Zrythm has a UI, 0 if headless (eg, when unit-testing).
Definition zrythm.h:175
qint64 ProcessId
GPid equivalent.
Definition types.h:55
Represents a semantic version with major, minor, and optional patch.
Definition version.h:29
API for Symap, a basic symbol map (string interner).