Zrythm v2.0.0-DEV
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
38using bpm_t = float;
39
40using curviness_t = double;
41
43using signed_frame_t = int_fast64_t;
44
46using unsigned_frame_t = uint_fast64_t;
47
50
53
55using ProcessId = qint64;
56
60using GenericFloatGetter = std::function<float ()>;
61
65using GenericFloatSetter = std::function<void (float)>;
66
70using GenericStringGetter = std::function<std::string ()>;
71
75using GenericStringSetter = std::function<void (const std::string &)>;
76
80using GenericCallback = std::function<void ()>;
81
82using GenericBoolGetter = std::function<bool ()>;
83
85{
88
91
94};
95
99enum class BeatUnit
100{
101 Two,
102 Four,
103 Eight,
104 Sixteen
105};
106
107/* types for simple timestamps/durations */
108using SteadyClock = std::chrono::steady_clock;
109using SteadyTimePoint = SteadyClock::time_point;
110using SteadyDuration = SteadyClock::duration;
111
112namespace fs = std::filesystem;
113
114#define ZRYTHM_IS_QT_THREAD (QThread::currentThread () == qApp->thread ())
115
116template <typename T>
117std::string
118typename_to_string ()
119{
120 return typeid (T).name ();
121}
122
123#define Z_DISABLE_COPY_MOVE(Class) Q_DISABLE_COPY_MOVE (Class)
124#define Z_DISABLE_COPY(Class) Q_DISABLE_COPY (Class)
125#define Z_DISABLE_MOVE(Class) \
126 Class (Class &&) = delete; \
127 Class &operator= (Class &&) = delete;
128
129template <typename Tuple, typename Callable>
130void
131iterate_tuple (Callable c, Tuple &&t)
132{
133 std::apply ([&] (auto &&... args) { (c (args), ...); }, t);
134}
135
136// We're using the C type here because MOC complains it can't find the type
137// otherwise (not even std::uint8_t)
138using basic_enum_base_type_t = uint8_t;
139
BeatUnit
Beat unit.
Definition types.h:100
std::function< float()> GenericFloatGetter
Getter prototype for float values.
Definition types.h:60
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
Definition types.h:46
std::function< void(float)> GenericFloatSetter
Setter prototype for float values.
Definition types.h:65
std::function< std::string()> GenericStringGetter
Getter prototype for strings.
Definition types.h:70
qint64 ProcessId
GPid equivalent.
Definition types.h:55
float audio_sample_type_t
The sample type.
Definition types.h:35
float bpm_t
The BPM type.
Definition types.h:38
signed_frame_t signed_ms_t
Signed millisecond index.
Definition types.h:49
signed_frame_t signed_sec_t
Signed second index.
Definition types.h:52
AudioValueFormat
Definition types.h:85
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:75
std::function< void()> GenericCallback
Generic callback.
Definition types.h:80
int_fast64_t signed_frame_t
Signed type for frame index.
Definition types.h:43
@ DBFS
dbFS.
Definition types.h:90
@ Fader
0 to 1, suitable for drawing.
Definition types.h:93
@ Amplitude
0 to 2, amplitude.
Definition types.h:87