Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __UTILS_TYPES_H__
11#define __UTILS_TYPES_H__
12
13#include <cstdint>
14
15#include "gtk_wrapper.h"
16#include <cinttypes>
17
18#pragma GCC diagnostic push
19#pragma GCC diagnostic ignored "-Wshadow"
20#include <magic_enum_all.hpp>
21#pragma GCC diagnostic pop
22
23using namespace magic_enum::bitwise_operators;
24
31#define TYPEDEF_STRUCT(s) typedef struct s s
32
33#define TYPEDEF_STRUCT_UNDERSCORED(s) typedef struct _##s s
34
36typedef uint8_t midi_byte_t;
37
39typedef uint32_t nframes_t;
40
42typedef uint32_t sample_rate_t;
43
45typedef uint32_t midi_time_t;
46
48typedef unsigned int channels_t;
49
51typedef float sample_t;
52
54typedef float bpm_t;
55
56typedef double curviness_t;
57
59typedef int_fast64_t signed_frame_t;
60
61#define SIGNED_FRAME_FORMAT PRId64
62
64typedef uint_fast64_t unsigned_frame_t;
65
66#define UNSIGNED_FRAME_FORMAT PRIu64
67
70
73
77typedef float (*GenericFloatGetter) (void * object);
78
82typedef void (*GenericFloatSetter) (void * object, float val);
83
87typedef const char * (*GenericStringGetter) (void * object);
88
92typedef void (*GenericStringSetter) (void * object, const char * val);
93
98typedef void (*GenericStringCopyGetter) (void * object, char * buf);
99
103typedef void (*GenericCallback) (void * object);
104
108typedef int (*GenericCmpFunc) (const void * a, const void * b);
109
116typedef bool (
117 *GenericPredicateFunc) (const void * object, const void * user_data);
118
122typedef void (*ObjectFreeFunc) (void *);
123
135
159
160static inline void
161engine_process_time_info_print (const EngineProcessTimeInfo * self)
162{
163 g_message (
164 "Global start frame: %" PRIuFAST64 " (with offset %" PRIuFAST64
165 ") | local offset: %" PRIu32 " | num frames: %" PRIu32,
167 self->nframes);
168}
169
170typedef enum CacheTypes
171{
172 CACHE_TYPE_TRACK_NAME_HASHES = 1 << 0,
173 CACHE_TYPE_PLUGIN_PORTS = 1 << 1,
174 CACHE_TYPE_PLAYBACK_SNAPSHOTS = 1 << 2,
175 CACHE_TYPE_AUTOMATION_LANE_RECORD_MODES = 1 << 3,
176 CACHE_TYPE_AUTOMATION_LANE_PORTS = 1 << 4,
177} CacheTypes;
178
179#define CACHE_TYPE_ALL \
180 (CACHE_TYPE_TRACK_NAME_HASHES | CACHE_TYPE_PLUGIN_PORTS \
181 | CACHE_TYPE_PLAYBACK_SNAPSHOTS | CACHE_TYPE_AUTOMATION_LANE_RECORD_MODES \
182 | CACHE_TYPE_AUTOMATION_LANE_PORTS)
183
184#define ENUM_INT_TO_VALUE_CONST(_enum, _int) \
185 (magic_enum::enum_value<_enum, _int> ())
186#define ENUM_INT_TO_VALUE(_enum, _int) (magic_enum::enum_value<_enum> (_int))
187#define ENUM_VALUE_TO_INT(_val) (magic_enum::enum_integer (_val))
188
189#define ENUM_ENABLE_BITSET(_enum) \
190 template <> struct magic_enum::customize::enum_range<_enum> \
191 { \
192 static constexpr bool is_flags = true; \
193 }
194#define ENUM_BITSET(_enum, _val) (magic_enum::containers::bitset<_enum> (_val))
195#define ENUM_BITSET_TEST(_enum, _val, _other_val) \
196 /* (ENUM_BITSET (_enum, _val).test (_other_val)) */ \
197 (static_cast<int> (_val) & static_cast<int> (_other_val))
198
201#define ENUM_BITSET_TO_STRING(_enum, _val) \
202 (ENUM_BITSET (_enum, _val).to_string ().data ())
203
204#define ENUM_COUNT(_enum) (magic_enum::enum_count<_enum> ())
205#define ENUM_NAME(_val) (magic_enum::enum_name (_val).data ())
206#define ENUM_NAME_FROM_INT(_enum, _int) \
207 ENUM_NAME (ENUM_INT_TO_VALUE (_enum, _int))
208
213#endif
void(* GenericStringSetter)(void *object, const char *val)
Setter prototype for float values.
Definition types.h:92
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
Definition types.h:64
uint32_t sample_rate_t
Sample rate.
Definition types.h:42
void(* GenericStringCopyGetter)(void *object, char *buf)
Getter prototype for strings to be saved in the given buffer.
Definition types.h:98
bool(* GenericPredicateFunc)(const void *object, const void *user_data)
Predicate function prototype.
Definition types.h:117
float(* GenericFloatGetter)(void *object)
Getter prototype for float values.
Definition types.h:77
signed_frame_t signed_sec_t
Signed second index.
Definition types.h:72
float bpm_t
The BPM type.
Definition types.h:54
int_fast64_t signed_frame_t
Signed type for frame index.
Definition types.h:59
signed_frame_t signed_ms_t
Signed millisecond index.
Definition types.h:69
uint32_t nframes_t
Frame count.
Definition types.h:39
void(* GenericCallback)(void *object)
Generic callback.
Definition types.h:103
void(* GenericFloatSetter)(void *object, float val)
Setter prototype for float values.
Definition types.h:82
uint32_t midi_time_t
MIDI time in global frames.
Definition types.h:45
uint8_t midi_byte_t
MIDI byte.
Definition types.h:36
void(* ObjectFreeFunc)(void *)
Function to call to free objects.
Definition types.h:122
float sample_t
The sample type.
Definition types.h:51
int(* GenericCmpFunc)(const void *a, const void *b)
Generic comparator.
Definition types.h:108
AudioValueFormat
Definition types.h:125
unsigned int channels_t
Number of channels.
Definition types.h:48
@ AUDIO_VALUE_DBFS
dbFS.
Definition types.h:130
@ AUDIO_VALUE_FADER
0 to 1, suitable for drawing.
Definition types.h:133
@ AUDIO_VALUE_AMPLITUDE
0 to 2, amplitude.
Definition types.h:127
Common struct to pass around during processing to avoid repeating the data in function arguments.
Definition types.h:142
unsigned_frame_t g_start_frame
Global position at the start of the processing cycle (no offset added).
Definition types.h:144
unsigned_frame_t g_start_frame_w_offset
Global position with EngineProcessTimeInfo.local_offset added, for convenience.
Definition types.h:148
nframes_t nframes
Number of frames to process in this call, starting from the offset.
Definition types.h:157
nframes_t local_offset
Offset in the current processing cycle, between 0 and the number of frames in AudioEngine....
Definition types.h:152