Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
types.h
1// SPDX-FileCopyrightText: © 2019-2022, 2024-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "zrythm-config.h"
7
8#include <chrono>
9#include <cinttypes>
10#include <cstdint>
11#include <filesystem>
12#include <functional>
13
14#include <QtTypes>
15
16#include <gsl-lite/gsl-lite.hpp>
17
18using namespace std::literals;
19namespace gsl = ::gsl_lite;
20
26
27// qint64
28using RtTimePoint = int64_t;
29using RtDuration = int64_t;
30
32using channels_t = uint_fast8_t;
33
35using audio_sample_type_t = float;
36
37using curviness_t = double;
38
40using signed_frame_t = int_fast64_t;
41
43using unsigned_frame_t = uint_fast64_t;
44
47
50
52using ProcessId = qint64;
53
57using GenericFloatGetter = std::function<float ()>;
58
62using GenericFloatSetter = std::function<void (float)>;
63
67using GenericStringGetter = std::function<std::string ()>;
68
72using GenericStringSetter = std::function<void (const std::string &)>;
73
77using GenericCallback = std::function<void ()>;
78
79using GenericBoolGetter = std::function<bool ()>;
80
84enum class BeatUnit
85{
86 Two,
87 Four,
88 Eight,
89 Sixteen
90};
91
92/* types for simple timestamps/durations */
93using SteadyClock = std::chrono::steady_clock;
94using SteadyTimePoint = SteadyClock::time_point;
95using SteadyDuration = SteadyClock::duration;
96
97namespace fs = std::filesystem;
98
99#define ZRYTHM_IS_QT_THREAD (QThread::currentThread () == qApp->thread ())
100
101template <typename T>
102std::string
103typename_to_string ()
104{
105 return typeid (T).name ();
106}
107
108#define Z_DISABLE_COPY_MOVE(Class) Q_DISABLE_COPY_MOVE (Class)
109#define Z_DISABLE_COPY(Class) Q_DISABLE_COPY (Class)
110#define Z_DISABLE_MOVE(Class) \
111 Class (Class &&) = delete; \
112 Class &operator= (Class &&) = delete;
113
114template <typename Tuple, typename Callable>
115void
116iterate_tuple (Callable c, Tuple &&t)
117{
118 std::apply ([&] (auto &&... args) { (c (args), ...); }, t);
119}
120
121// We're using the C type here because MOC complains it can't find the type
122// otherwise (not even std::uint8_t)
123using basic_enum_base_type_t = uint8_t;
124
BeatUnit
Beat unit.
Definition types.h:85
std::function< float()> GenericFloatGetter
Getter prototype for float values.
Definition types.h:57
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
Definition types.h:43
std::function< void(float)> GenericFloatSetter
Setter prototype for float values.
Definition types.h:62
std::function< std::string()> GenericStringGetter
Getter prototype for strings.
Definition types.h:67
qint64 ProcessId
GPid equivalent.
Definition types.h:52
float audio_sample_type_t
The sample type.
Definition types.h:35
signed_frame_t signed_ms_t
Signed millisecond index.
Definition types.h:46
signed_frame_t signed_sec_t
Signed second index.
Definition types.h:49
uint_fast8_t channels_t
Number of channels.
Definition types.h:32
std::function< void(const std::string &)> GenericStringSetter
Setter prototype for float values.
Definition types.h:72
std::function< void()> GenericCallback
Generic callback.
Definition types.h:77
int_fast64_t signed_frame_t
Signed type for frame index.
Definition types.h:40