6#include "zrythm-config.h"
15#include <gsl-lite/gsl-lite.hpp>
17#if defined(__GNUC__) || defined(__clang__)
18# pragma GCC diagnostic push
19# pragma GCC diagnostic ignored "-Wshadow"
22# pragma warning(disable : 4458)
25#include <magic_enum_all.hpp>
27#if defined(__GNUC__) || defined(__clang__)
28# pragma GCC diagnostic pop
33using namespace magic_enum::bitwise_operators;
34using namespace std::literals;
35namespace gsl = ::gsl_lite;
39operator""_zu (
unsigned long long int x)
41 return static_cast<size_t> (x);
51using RtTimePoint = int64_t;
52using RtDuration = int64_t;
72using curviness_t = double;
114using GenericBoolGetter = std::function<bool ()>;
188#define ENUM_INT_TO_VALUE_CONST(_enum, _int) \
189 (magic_enum::enum_value<_enum, _int> ())
190#define ENUM_INT_TO_VALUE(_enum, _int) (magic_enum::enum_value<_enum> (_int))
191#define ENUM_VALUE_TO_INT(_val) (magic_enum::enum_integer (_val))
193#define ENUM_ENABLE_BITSET(_enum) \
194 template <> struct magic_enum::customize::enum_range<_enum> \
196 static constexpr bool is_flags = true; \
198#define ENUM_BITSET(_enum, _val) (magic_enum::containers::bitset<_enum> (_val))
199#define ENUM_BITSET_TEST(_val, _other_val) \
201 (static_cast<std::underlying_type_t<decltype (_val)>> (_val) \
202 & static_cast<std::underlying_type_t<decltype (_val)>> (_other_val))
206#define ENUM_BITSET_TO_STRING(_enum, _val) \
207 (ENUM_BITSET (_enum, _val).to_string ().data ())
209#define ENUM_COUNT(_enum) (magic_enum::enum_count<_enum> ())
210#define ENUM_NAME(_val) (magic_enum::enum_name (_val).data ())
211#define ENUM_NAME_FROM_INT(_enum, _int) \
212 ENUM_NAME (ENUM_INT_TO_VALUE (_enum, _int))
218 PlaybackSnapshots = 1 << 2,
219 AutomationLaneRecordModes = 1 << 3,
220 AutomationLanePorts = 1 << 4,
223ENUM_ENABLE_BITSET (CacheType);
225constexpr CacheType ALL_CACHE_TYPES =
226 CacheType::PlaybackSnapshots | CacheType::AutomationLaneRecordModes
227 | CacheType::AutomationLanePorts;
230using SteadyClock = std::chrono::steady_clock;
231using SteadyTimePoint = SteadyClock::time_point;
232using SteadyDuration = SteadyClock::duration;
234namespace fs = std::filesystem;
236#define ZRYTHM_IS_QT_THREAD (QThread::currentThread () == qApp->thread ())
242 return typeid (T).name ();
245#define Z_DISABLE_COPY_MOVE(Class) Q_DISABLE_COPY_MOVE (Class)
246#define Z_DISABLE_COPY(Class) Q_DISABLE_COPY (Class)
247#define Z_DISABLE_MOVE(Class) \
248 Class (Class &&) = delete; \
249 Class &operator= (Class &&) = delete;
263template <
typename T>
struct OptionalRef
265 OptionalRef () =
default;
266 OptionalRef (std::nullopt_t) { }
267 OptionalRef (T &ref) : ref_ (ref) { }
269 std::optional<std::reference_wrapper<T>> ref_;
287 const T * operator->()
const
290 return std::addressof (ref_->get ());
295 return std::addressof (ref_->get ());
298 explicit operator bool ()
const {
return has_value (); }
319template <
typename Tuple,
typename Callable>
321iterate_tuple (Callable c, Tuple &&t)
323 std::apply ([&] (
auto &&... args) { (c (args), ...); }, t);
328using basic_enum_base_type_t = uint8_t;
std::function< float()> GenericFloatGetter
Getter prototype for float values.
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
std::function< void(float)> GenericFloatSetter
Setter prototype for float values.
std::function< std::string()> GenericStringGetter
Getter prototype for strings.
qint64 ProcessId
GPid equivalent.
uint32_t nframes_t
Frame count.
float audio_sample_type_t
The sample type.
uint32_t midi_time_t
MIDI time in global frames.
signed_frame_t signed_ms_t
Signed millisecond index.
signed_frame_t signed_sec_t
Signed second index.
uint_fast8_t channels_t
Number of channels.
std::function< void(const std::string &)> GenericStringSetter
Setter prototype for float values.
std::function< void()> GenericCallback
Generic callback.
int_fast64_t signed_frame_t
Signed type for frame index.
uint8_t midi_byte_t
MIDI byte.
@ Musical
Musical time (ticks).
@ Absolute
Absolute time (seconds).
@ Fader
0 to 1, suitable for drawing.
@ Amplitude
0 to 2, amplitude.
Common struct to pass around during processing to avoid repeating the data in function arguments.
nframes_t local_offset_
Offset in the current processing cycle, between 0 and the number of frames in AudioEngine....
unsigned_frame_t g_start_frame_
Global position at the start of the processing cycle (no offset added).
unsigned_frame_t g_start_frame_w_offset_
Global position with EngineProcessTimeInfo.local_offset added, for convenience.
nframes_t nframes_
Number of frames to process in this call, starting from the offset.
bool looping_
Transport loop.
bool running_
Engine running.
bool has_value() const
Check if a value is present.
T & operator*()
Dereference the underlying value.
T & value()
Get a reference to the underlying value.