Zrythm
a highly automated and intuitive digital audio workstation
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
zrythm.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __ZRYTHM_H__
11#define __ZRYTHM_H__
12
13#include "zrythm-config.h"
14
15#include <memory>
16
17#include <gio/gio.h>
18#include <glib.h>
19
20#include "ext/juce/juce.h"
21#include "zix/sem.h"
22
23typedef struct Project Project;
24typedef struct Symap Symap;
26typedef struct EventManager EventManager;
27typedef struct PluginManager PluginManager;
28typedef struct FileManager FileManager;
30class Settings;
31typedef struct Log Log;
32typedef struct CairoCaches CairoCaches;
33typedef struct PCGRand PCGRand;
34class StringArray;
35
42#define ZRYTHM_PROJECTS_DIR "projects"
43
44#define MAX_RECENT_PROJECTS 20
45#define DEBUGGING (G_UNLIKELY (gZrythm && gZrythm->debug))
46#define ZRYTHM_TESTING (g_test_initialized ())
47#define ZRYTHM_GENERATING_PROJECT (gZrythm->generating_project)
48#define ZRYTHM_HAVE_UI (gZrythm && gZrythm->have_ui_)
49
50#ifdef HAVE_LSP_DSP
51# define ZRYTHM_USE_OPTIMIZED_DSP (G_LIKELY (gZrythm->use_optimized_dsp))
52#else
53# define ZRYTHM_USE_OPTIMIZED_DSP false
54#endif
55
177
179{
180public:
189 char * get_user_dir (bool force_default);
190
197
204 char * get_dir (ZrythmDirType type);
205
207 char * testing_dir = nullptr;
208};
209
216{
217public:
222 explicit Zrythm (const char * exe_path, bool have_ui, bool optimized_dsp);
223
224 ~Zrythm ();
225
226 void init ();
227
228 void add_to_recent_projects (const char * filepath);
229
230 void remove_recent_project (char * filepath);
231
239 static char * get_version (bool with_v);
240
247 static bool is_release (bool official);
248
249 static char *
250 fetch_latest_release_ver_finish (GAsyncResult * result, GError ** error);
251
258 GAsyncReadyCallback callback,
259 gpointer callback_data);
260
265 static bool is_latest_release (const char * remote_latest_release);
266
274 static void
275 get_version_with_capabilities (char * buf, bool include_system_info);
276
281 static char * get_system_info ();
282
293 static char * get_prefix ();
294
301 bool init_user_dirs_and_files (GError ** error);
302
307
309 const char * exe_path_ = nullptr;
310
315
319 std::unique_ptr<Settings> settings;
320
328 Project * project = nullptr;
329
331 std::unique_ptr<StringArray> recent_projects_;
332
334 char ** templates = nullptr;
335
341 char * demo_template = nullptr;
342
345 bool opening_template = false;
346
348 bool creating_project = false;
349
351 char * create_project_path = nullptr;
352
360 char * open_filename = nullptr;
361
362 EventManager * event_manager = nullptr;
363
366
369
372
373 std::unique_ptr<ZrythmDirectoryManager> dir_mgr;
374
378 Symap * symap = nullptr;
379
384
386 PCGRand * rand = nullptr;
387
391 bool debug = false;
392
395 bool generating_project = false;
396
399 bool have_ui_ = false;
400
402 bool use_optimized_dsp = false;
403
404 CairoCaches * cairo_caches = nullptr;
405
408
410 char * version = nullptr;
411
417 bool open_newer_backup = false;
418
428
430 GPid pipewire_pid = 0;
431
432 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Zrythm)
433};
434
438extern std::unique_ptr<Zrythm> gZrythm;
439
444#endif /* __ZRYTHM_H__ */
String array that auto-converts given char pointers to UTF8 (so JUCE doesn't complain.
Definition string.h:52
char * get_user_dir(bool force_default)
Gets the zrythm directory, either from the settings if non-empty, or the default ($XDG_DATA_DIR/zryth...
char * get_default_user_dir()
Returns the default user "zrythm" dir.
char * testing_dir
Zrythm directory used during unit tests.
Definition zrythm.h:207
char * get_dir(ZrythmDirType type)
Returns a Zrythm directory specified by type.
To be used throughout the program.
Definition zrythm.h:216
bool opening_template
Whether the open file is a template to be used to create a new project from.
Definition zrythm.h:345
Symap * symap
String interner for internal things.
Definition zrythm.h:378
FileManager * file_manager
File manager.
Definition zrythm.h:368
bool init_user_dirs_and_files(GError **error)
Initializes/creates the default dirs/files in the user directory.
bool have_ui_
1 if Zrythm has a UI, 0 if headless (eg, when unit-testing).
Definition zrythm.h:399
std::unique_ptr< Settings > settings
Application settings.
Definition zrythm.h:319
char ** templates
NULL terminated array of project template absolute paths.
Definition zrythm.h:334
bool debug
In debug mode or not (determined by GSetting).
Definition zrythm.h:391
PCGRand * rand
Random number generator.
Definition zrythm.h:386
char * demo_template
Demo project template used when running for the first time.
Definition zrythm.h:341
RecordingManager * recording_manager
Recording manager.
Definition zrythm.h:365
char * open_filename
Filename to open passed through the command line.
Definition zrythm.h:360
static char * get_version(bool with_v)
Returns the version string.
static void fetch_latest_release_ver_async(GAsyncReadyCallback callback, gpointer callback_data)
Project * project
Project data.
Definition zrythm.h:328
int undo_stack_len
Undo stack length, used during tests.
Definition zrythm.h:407
static void get_version_with_capabilities(char *buf, bool include_system_info)
Returns the version and the capabilities.
static char * get_prefix()
Returns the prefix or in the case of windows the root dir (C/program files/zrythm) or in the case of ...
const char * exe_path_
argv[0].
Definition zrythm.h:309
GPid pipewire_pid
Process ID for pipewire (used in tests).
Definition zrythm.h:430
std::unique_ptr< StringArray > recent_projects_
+1 to ensure last element is NULL in case full.
Definition zrythm.h:331
bool generating_project
Whether this is a dummy instance used when generating projects.
Definition zrythm.h:395
static bool is_latest_release(const char *remote_latest_release)
Returns whether the given release string is the latest release.
char * create_project_path
Path to create a project in, including its title.
Definition zrythm.h:351
void init_templates()
Initializes the array of project templates.
Symap * error_domain_symap
String interner for error domains.
Definition zrythm.h:383
bool use_pipewire_in_tests
Whether to use pipewire in tests.
Definition zrythm.h:427
ChordPresetPackManager * chord_preset_pack_manager
Chord preset pack manager.
Definition zrythm.h:371
static char * get_system_info()
Returns system info (mainly used for bug reports).
char * version
Cached version (without 'v').
Definition zrythm.h:410
Zrythm(const char *exe_path, bool have_ui, bool optimized_dsp)
PluginManager * plugin_manager
Manages plugins (loading, instantiating, etc.)
Definition zrythm.h:314
bool open_newer_backup
Whether to open a newer backup if found.
Definition zrythm.h:417
bool use_optimized_dsp
Whether to use optimized DSP when available.
Definition zrythm.h:402
static bool is_release(bool official)
Returns whether the current Zrythm version is a release version.
bool creating_project
Whether creating a new project, either from a template or blank.
Definition zrythm.h:348
ZrythmDirType
Type of Zrythm directory.
Definition zrythm.h:60
std::unique_ptr< Zrythm > gZrythm
Global variable, should be available to all files.
@ ZRYTHM_DIR_SYSTEM_THEMESDIR
Themes.
Definition zrythm.h:117
@ ZRYTHM_DIR_USER_GDB
Gdb backtrace files.
Definition zrythm.h:171
@ ZRYTHM_DIR_USER_PROJECTS
Subdirs of ZRYTHM_DIR_USER_TOP.
Definition zrythm.h:151
@ ZRYTHM_DIR_USER_BACKTRACE
Backtraces.
Definition zrythm.h:174
@ ZRYTHM_DIR_USER_PROFILING
Profiling files.
Definition zrythm.h:168
@ ZRYTHM_DIR_SYSTEM_PARENT_LIBDIR
libdir name under ZRYTHM_DIR_SYSTEM_PREFIX.
Definition zrythm.h:84
@ ZRYTHM_DIR_SYSTEM_SPECIAL_LV2_PLUGINS_DIR
Special external Zrythm plugins path (not part of the Zrythm source code).
Definition zrythm.h:130
@ ZRYTHM_DIR_SYSTEM_PREFIX
The prefix, or in the case of windows installer the root dir (C/program files/zrythm),...
Definition zrythm.h:74
@ ZRYTHM_DIR_SYSTEM_ZRYTHM_LIBDIR
libdir/zrythm
Definition zrythm.h:87
@ ZRYTHM_DIR_SYSTEM_ZRYTHM_DATADIR
share/zrythm
Definition zrythm.h:108
@ ZRYTHM_DIR_USER_TOP
Main zrythm directory from gsettings.
Definition zrythm.h:148
@ ZRYTHM_DIR_USER_THEMES_CSS
User CSS themes.
Definition zrythm.h:156
@ ZRYTHM_DIR_SYSTEM_SCRIPTSDIR
Scripts.
Definition zrythm.h:114
@ ZRYTHM_DIR_USER_SCRIPTS
User scripts.
Definition zrythm.h:162
@ ZRYTHM_DIR_SYSTEM_BUNDLED_PLUGINSDIR
libdir/zrythm/lv2
Definition zrythm.h:90
@ ZRYTHM_DIR_SYSTEM_BUNDLED_SOURCEVIEW_LANGUAGE_SPECS_DIR
"gtksourceview-5/language-specs" under "share/zrythm".
Definition zrythm.h:105
@ ZRYTHM_DIR_SYSTEM_PARENT_DATADIR
"share" under ZRYTHM_DIR_SYSTEM_PREFIX.
Definition zrythm.h:80
@ ZRYTHM_DIR_SYSTEM_SAMPLESDIR
Samples.
Definition zrythm.h:111
@ ZRYTHM_DIR_SYSTEM_FONTSDIR
The directory fonts/zrythm under datadir.
Definition zrythm.h:133
@ ZRYTHM_DIR_SYSTEM_THEMES_ICONS_DIR
Icon themes.
Definition zrythm.h:123
@ ZRYTHM_DIR_USER_LOG
Log files.
Definition zrythm.h:165
@ ZRYTHM_DIR_USER_THEMES_ICONS
User icon themes.
Definition zrythm.h:159
@ ZRYTHM_DIR_SYSTEM_TEMPLATES
Project templates.
Definition zrythm.h:136
@ ZRYTHM_DIR_SYSTEM_THEMES_CSS_DIR
CSS themes.
Definition zrythm.h:120
@ ZRYTHM_DIR_SYSTEM_BINDIR
"bin" under ZRYTHM_DIR_SYSTEM_PREFIX.
Definition zrythm.h:77
@ ZRYTHM_DIR_SYSTEM_LOCALEDIR
Localization under "share".
Definition zrythm.h:93
@ ZRYTHM_DIR_SYSTEM_SOURCEVIEW_LANGUAGE_SPECS_DIR
"gtksourceview-5/language-specs" under "share".
Definition zrythm.h:99
Caches for cairo.
Definition cairo.h:29
Chord preset pack manager.
Event manager for the UI.
Definition log.h:22
The PluginManager is responsible for scanning and keeping track of available Plugin's.
Contains all of the info that will be serialized into a project file.
Definition project.h:145
Definition symap.h:36