Zrythm v2.0.0-alpha.1+31.4967fd053471
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/symap.h"
10#include "utils/types.h"
11#include "utils/utf8_string.h"
12#include "utils/version.h"
13
14#include <QtQmlIntegration/QtQmlIntegration>
15
16#include <juce_core/juce_core.h>
17
18class DspContextRAII;
19class Settings;
20
21namespace zrythm
22{
23
29
30#define MAX_RECENT_PROJECTS 20
31#define DEBUGGING (Q_UNLIKELY (gZrythm && gZrythm->debug_))
32#define ZRYTHM_BENCHMARKING (gZrythm && gZrythm->benchmarking_)
33#define ZRYTHM_GENERATING_PROJECT (gZrythm->generating_project_)
34#define ZRYTHM_HAVE_UI (gZrythm && gZrythm->have_ui_)
35#define ZRYTHM_BREAK_ON_ERROR (gZrythm && gZrythm->break_on_error_)
36
37#define ZRYTHM_USE_OPTIMIZED_DSP (Q_LIKELY (gZrythm->use_optimized_dsp_))
38
44class Zrythm final : public QObject, public utils::QElapsedTimeProvider
45{
46 Q_OBJECT
47 QML_ELEMENT
48 Q_PROPERTY (QString version READ getVersion CONSTANT FINAL)
49 QML_UNCREATABLE ("")
50public:
51 ~Zrythm () override;
52
61 void pre_init (
62 std::optional<std::filesystem::path> exe_path,
63 bool have_ui,
64 bool optimized_dsp);
65
66 void init ();
67
68 QString getVersion () const { return get_version (false).to_qstring (); }
69
75 static utils::Utf8String get_version (bool with_v);
76
81
88 static bool is_release (bool official);
89
94 static bool is_latest_release (const char * remote_latest_release);
95
103 static void
104 get_version_with_capabilities (char * buf, bool include_system_info);
105
110
117
118private:
119 Zrythm ();
120
121public:
123 std::filesystem::path exe_path_;
124
128 std::unique_ptr<Settings> settings_;
129
132 bool opening_template_ = false;
133
135 bool creating_project_ = false;
136
138 std::filesystem::path create_project_path_;
139
145 std::filesystem::path open_filename_;
146
151
155 bool debug_ = false;
156
158 bool break_on_error_ = false;
159
163
166 bool have_ui_ = false;
167
169 bool use_optimized_dsp_ = false;
170
173
179 bool open_newer_backup_ = false;
180
190
193
197 std::unique_ptr<DspContextRAII> lsp_dsp_context_;
198
202 bool benchmarking_ = false;
203
204 JUCE_DECLARE_SINGLETON_SINGLETHREADED (Zrythm, false)
205
206 JUCE_HEAVYWEIGHT_LEAK_DETECTOR (Zrythm)
207};
208
209} // namespace zrythm
210
211#define gZrythm (::zrythm::Zrythm::getInstanceWithoutCreating ())
212
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:197
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:169
bool debug_
In debug mode or not (determined by GSetting).
Definition zrythm.h:155
bool use_pipewire_in_tests_
Whether to use pipewire in tests.
Definition zrythm.h:189
bool open_newer_backup_
Whether to open a newer backup if found.
Definition zrythm.h:179
ProcessId pipewire_pid_
Process ID for pipewire (used in tests).
Definition zrythm.h:192
bool break_on_error_
Whether to abort() on an error log message.
Definition zrythm.h:158
int undo_stack_len_
Undo stack length, used during tests.
Definition zrythm.h:172
bool creating_project_
Whether creating a new project, either from a template or blank.
Definition zrythm.h:135
std::unique_ptr< Settings > settings_
Application settings.
Definition zrythm.h:128
std::filesystem::path open_filename_
Filename to open passed through the command line.
Definition zrythm.h:145
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:150
bool benchmarking_
Whether currently running under the benchmarker.
Definition zrythm.h:202
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().
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:162
std::filesystem::path exe_path_
argv[0].
Definition zrythm.h:123
std::filesystem::path create_project_path_
Path to create a project in, including its title.
Definition zrythm.h:138
bool opening_template_
Whether the open file is a template to be used to create a new project from.
Definition zrythm.h:132
bool have_ui_
1 if Zrythm has a UI, 0 if headless (eg, when unit-testing).
Definition zrythm.h:166
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).