Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
Utilities

Various utilities. More...

Data Structures

struct  PangoLayoutDeleter
class  zrythm::legacy::FileDescriptor
 Descriptor of a file. More...
class  UiColors
 Commonly used UI colors. More...
class  UiTextures
 Commonly used UI textures. More...
class  MPMCQueue< T >
 Multiple Producer Multiple Consumer lock-free queue. More...
class  Resampler
 Audio resampler. More...

Macros

#define SUPPORTED_FILE_DND_PREFIX   Z_DND_STRING_PREFIX "FileDescriptor::"
#define UI_CACHES   (zrythm_app->ui_caches_)
#define UI_COLORS   (&UI_CACHES->colors_)
#define z_return_val_if_fail_cmp(a, comparator, b, val)
#define z_return_if_fail_cmp(a, comparator, b)
#define z_warn_if_fail_cmp(a, comparator, b)
#define DEBUG_BREAK()
#define ZRYTHM_IS_QT_THREAD   (QThread::currentThread () == qApp->thread ())
#define Z_DISABLE_COPY_MOVE(Class)
#define Z_DISABLE_COPY(Class)
#define Z_DISABLE_MOVE(Class)

Typedefs

using PangoLayoutUniquePtr = std::unique_ptr<PangoLayout, PangoLayoutDeleter>
using Color = zrythm::utils::Color
using RtTimePoint = int64_t
using RtDuration = int64_t
using channels_t = uint_fast8_t
 Number of channels.
using audio_sample_type_t = float
 The sample type.
using bpm_t = float
 The BPM type.
using curviness_t = double
using signed_frame_t = int_fast64_t
 Signed type for frame index.
using unsigned_frame_t = uint_fast64_t
 Unsigned type for frame index.
using signed_ms_t = signed_frame_t
 Signed millisecond index.
using signed_sec_t = signed_frame_t
 Signed second index.
using ProcessId = qint64
 GPid equivalent.
using GenericFloatGetter = std::function<float ()>
 Getter prototype for float values.
using GenericFloatSetter = std::function<void (float)>
 Setter prototype for float values.
using GenericStringGetter = std::function<std::string ()>
 Getter prototype for strings.
using GenericStringSetter = std::function<void (const std::string &)>
 Setter prototype for float values.
using GenericCallback = std::function<void ()>
 Generic callback.
using GenericBoolGetter = std::function<bool ()>
using SteadyClock = std::chrono::steady_clock
using SteadyTimePoint = SteadyClock::time_point
using SteadyDuration = SteadyClock::duration
using basic_enum_base_type_t = uint8_t

Enumerations

enum class  zrythm::legacy::FileType {
  Midi , Mp3 , Flac , Ogg ,
  Wav , Directory , FileType::ParentDirectory , Other ,
  NumFileTypes
}
 File type. More...
enum class  UiCursorState {
  UI_CURSOR_STATE_DEFAULT , UI_CURSOR_STATE_RESIZE_L , UI_CURSOR_STATE_REPEAT_L , UI_CURSOR_STATE_RESIZE_R ,
  UI_CURSOR_STATE_REPEAT_R , UI_CURSOR_STATE_RESIZE_UP
}
 Various cursor states to be shared. More...
enum class  UiOverlayAction {
  None , CreatingResizingR , CREATING_MOVING , ResizingL ,
  ResizingLLoop , ResizingLFade , ResizingR , ResizingRLoop ,
  ResizingRFade , RESIZING_UP , RESIZING_UP_FADE_IN , RESIZING_UP_FADE_OUT ,
  StretchingL , StretchingR , STARTING_AUDITIONING , AUDITIONING ,
  UiOverlayAction::AUTOFILLING , UiOverlayAction::ERASING , STARTING_ERASING , UiOverlayAction::STARTING_MOVING ,
  STARTING_MOVING_COPY , STARTING_MOVING_LINK , MOVING , MovingCopy ,
  MOVING_LINK , STARTING_CHANGING_CURVE , CHANGING_CURVE , UiOverlayAction::STARTING_SELECTION ,
  SELECTING , UiOverlayAction::STARTING_DELETE_SELECTION , DELETE_SELECTING , STARTING_RAMP ,
  RAMPING , CUTTING , RENAMING , StartingPanning ,
  Panning , NUM_UI_OVERLAY_ACTIONS
}
 Various overlay actions to be shared. More...
enum class  AudioValueFormat { AudioValueFormat::Amplitude , AudioValueFormat::DBFS , AudioValueFormat::Fader }
enum class  BeatUnit { Two , Four , Eight , Sixteen }
 Beat unit. More...

Functions

PangoLayoutUniquePtr z_pango_create_layout_from_description (GtkWidget *widget, PangoFontDescription *descr)
 DEFINE_ENUM_FORMATTER (UiOverlayAction, UiOverlayAction, "NONE", "RESIZING_R", "MOVING", "RESIZING_L", "RESIZING_L_LOOP", "RESIZING_L_FADE", "RESIZING_R", "RESIZING_R_LOOP", "RESIZING_R_FADE", "RESIZING_UP", "RESIZING_UP_FADE_IN", "RESIZING_UP_FADE_OUT", "STRETCHING_L", "STRETCHING_R", "STARTING_AUDITIONING", "AUDITIONING", "AUTOFILLING", "ERASING", "STARTING_ERASING", "STARTING_MOVING", "STARTING_MOVING_COPY", "STARTING_MOVING_LINK", "MOVING", "MOVING_COPY", "MOVING_LINK", "STARTING_CHANGING_CURVE", "CHANGING_CURVE", "STARTING_SELECTION", "SELECTING", "STARTING_DELETE_SELECTION", "DELETE_SELECTING", "STARTING_RAMP", "RAMPING", "CUTTING", "RENAMING", "STARTING_PANNING", "PANNING", "--INVALID--") enum class UiDragMode
 Dragging modes for widgets that have click&drag.
double ui_get_normalized_draggable_value (double size, double cur_val, double start_px, double cur_px, double last_px, double multiplier, UiDragMode mode)
 Gets a draggable value as a normalized value between 0 and 1.
std::string ui_get_db_value_as_string (float val)
 Returns an appropriate string representation of the given dB value.
int env_get_int (const char *key, int def)
 Returns an int for the given environment variable if it exists and is valid, otherwise returns the default int.
template<typename T>
std::string typename_to_string ()
template<typename Tuple, typename Callable>
void iterate_tuple (Callable c, Tuple &&t)

Variables

constexpr const char * UI_COLOR_DARK_TEXT = "#323232"
constexpr const char * UI_COLOR_BRIGHT_TEXT = "#cdcdcd"
constexpr const char * UI_COLOR_YELLOW = "#F9CA1B"
constexpr const char * UI_COLOR_PURPLE = "#9D3955"
constexpr const char * UI_COLOR_BUTTON_NORMAL = "#343434"
constexpr const char * UI_COLOR_BUTTON_HOVER = "#444444"
constexpr const char * UI_COLOR_RECORD_CHECKED = "#ED2939"
constexpr const char * UI_COLOR_RECORD_ACTIVE = "#FF2400"
constexpr const char * UI_COLOR_BRIGHT_GREEN = "#1DD169"
constexpr const char * UI_COLOR_DARKISH_GREEN = "#19664c"
constexpr const char * UI_COLOR_DARK_ORANGE = "#D68A0C"
constexpr const char * UI_COLOR_Z_YELLOW = "#F9CA1B"
constexpr const char * UI_COLOR_BRIGHT_ORANGE = "#F79616"
constexpr const char * UI_COLOR_Z_PURPLE = "#9D3955"
constexpr const char * UI_COLOR_MATCHA = "#2eb398"
constexpr const char * UI_COLOR_LIGHT_BLUEISH = "#1aa3ffcc"
constexpr const char * UI_COLOR_PREFADER_SEND = "#D21E6D"
constexpr const char * UI_COLOR_POSTFADER_SEND = "#901ed2"
constexpr const char * UI_COLOR_SOLO_ACTIVE = UI_COLOR_MATCHA
constexpr const char * UI_COLOR_SOLO_CHECKED = UI_COLOR_DARKISH_GREEN
constexpr const char * UI_COLOR_HIGHLIGHT_SCALE_BG = "#662266"
constexpr const char * UI_COLOR_HIGHLIGHT_CHORD_BG = "#BB22BB"
constexpr const char * UI_COLOR_HIGHLIGHT_BASS_BG = UI_COLOR_LIGHT_BLUEISH
constexpr const char * UI_COLOR_HIGHLIGHT_BOTH_BG = "#FF22FF"
constexpr const char * UI_COLOR_HIGHLIGHT_SCALE_FG = "#F79616"
constexpr const char * UI_COLOR_HIGHLIGHT_CHORD_FG = UI_COLOR_HIGHLIGHT_SCALE_FG
constexpr const char * UI_COLOR_HIGHLIGHT_BASS_FG = "white"
constexpr const char * UI_COLOR_HIGHLIGHT_BOTH_FG = "white"
constexpr const char * UI_COLOR_FADER_FILL_END = UI_COLOR_Z_YELLOW
constexpr const char * UI_DELETE_ICON_NAME = "z-edit-delete"

Detailed Description

Various utilities.

Macro Definition Documentation

◆ DEBUG_BREAK

#define DEBUG_BREAK ( )
Value:
do \
{ \
volatile int * p = 0; \
*p = 0; \
} \
while (0)

Definition at line 46 of file debug.h.

◆ SUPPORTED_FILE_DND_PREFIX

#define SUPPORTED_FILE_DND_PREFIX   Z_DND_STRING_PREFIX "FileDescriptor::"

Definition at line 19 of file file_descriptor.h.

◆ UI_CACHES

#define UI_CACHES   (zrythm_app->ui_caches_)

Definition at line 23 of file ui.h.

◆ UI_COLORS

#define UI_COLORS   (&UI_CACHES->colors_)

Definition at line 24 of file ui.h.

◆ Z_DISABLE_COPY

#define Z_DISABLE_COPY ( Class)
Value:
Q_DISABLE_COPY (Class)

Definition at line 124 of file types.h.

◆ Z_DISABLE_COPY_MOVE

#define Z_DISABLE_COPY_MOVE ( Class)
Value:
Q_DISABLE_COPY_MOVE (Class)

Definition at line 123 of file types.h.

◆ Z_DISABLE_MOVE

#define Z_DISABLE_MOVE ( Class)
Value:
Class (Class &&) = delete; \
Class &operator= (Class &&) = delete;

Definition at line 125 of file types.h.

◆ z_return_if_fail_cmp

#define z_return_if_fail_cmp ( a,
comparator,
b )
Value:
z_return_val_if_fail_cmp (a, comparator, b, )

Definition at line 23 of file debug.h.

◆ z_return_val_if_fail_cmp

#define z_return_val_if_fail_cmp ( a,
comparator,
b,
val )
Value:
if (!((a) comparator (b))) [[unlikely]] \
{ \
z_error ( \
"Assertion failed: `{}` ({}) {} `{}` ({})", #a, (a), #comparator, #b, \
(b)); \
return val; \
}

Definition at line 14 of file debug.h.

◆ z_warn_if_fail_cmp

#define z_warn_if_fail_cmp ( a,
comparator,
b )
Value:
if (!((a) comparator (b))) [[unlikely]] \
{ \
z_warning ( \
"Assertion failed: `{}` ({}) {} `{}` ({})", #a, (a), #comparator, #b, \
(b)); \
}

Definition at line 26 of file debug.h.

◆ ZRYTHM_IS_QT_THREAD

#define ZRYTHM_IS_QT_THREAD   (QThread::currentThread () == qApp->thread ())

Definition at line 114 of file types.h.

Typedef Documentation

◆ audio_sample_type_t

using audio_sample_type_t = float

The sample type.

Definition at line 35 of file types.h.

◆ basic_enum_base_type_t

using basic_enum_base_type_t = uint8_t

Definition at line 138 of file types.h.

◆ bpm_t

using bpm_t = float

The BPM type.

Definition at line 38 of file types.h.

◆ channels_t

using channels_t = uint_fast8_t

Number of channels.

Definition at line 32 of file types.h.

◆ Color

using Color = zrythm::utils::Color

Definition at line 58 of file ui.h.

◆ curviness_t

using curviness_t = double

Definition at line 40 of file types.h.

◆ GenericBoolGetter

using GenericBoolGetter = std::function<bool ()>

Definition at line 82 of file types.h.

◆ GenericCallback

using GenericCallback = std::function<void ()>

Generic callback.

Definition at line 80 of file types.h.

◆ GenericFloatGetter

using GenericFloatGetter = std::function<float ()>

Getter prototype for float values.

Definition at line 60 of file types.h.

◆ GenericFloatSetter

using GenericFloatSetter = std::function<void (float)>

Setter prototype for float values.

Definition at line 65 of file types.h.

◆ GenericStringGetter

using GenericStringGetter = std::function<std::string ()>

Getter prototype for strings.

Definition at line 70 of file types.h.

◆ GenericStringSetter

using GenericStringSetter = std::function<void (const std::string &)>

Setter prototype for float values.

Definition at line 75 of file types.h.

◆ PangoLayoutUniquePtr

using PangoLayoutUniquePtr = std::unique_ptr<PangoLayout, PangoLayoutDeleter>

Definition at line 33 of file pango.h.

◆ ProcessId

using ProcessId = qint64

GPid equivalent.

Definition at line 55 of file types.h.

◆ RtDuration

using RtDuration = int64_t

Definition at line 29 of file types.h.

◆ RtTimePoint

using RtTimePoint = int64_t

Definition at line 28 of file types.h.

◆ signed_frame_t

using signed_frame_t = int_fast64_t

Signed type for frame index.

Definition at line 43 of file types.h.

◆ signed_ms_t

Signed millisecond index.

Definition at line 49 of file types.h.

◆ signed_sec_t

Signed second index.

Definition at line 52 of file types.h.

◆ SteadyClock

using SteadyClock = std::chrono::steady_clock

Definition at line 108 of file types.h.

◆ SteadyDuration

using SteadyDuration = SteadyClock::duration

Definition at line 110 of file types.h.

◆ SteadyTimePoint

using SteadyTimePoint = SteadyClock::time_point

Definition at line 109 of file types.h.

◆ unsigned_frame_t

using unsigned_frame_t = uint_fast64_t

Unsigned type for frame index.

Definition at line 46 of file types.h.

Enumeration Type Documentation

◆ AudioValueFormat

enum class AudioValueFormat
strong
Enumerator
Amplitude 

0 to 2, amplitude.

DBFS 

dbFS.

Fader 

0 to 1, suitable for drawing.

Definition at line 84 of file types.h.

◆ BeatUnit

enum class BeatUnit
strong

Beat unit.

Definition at line 99 of file types.h.

◆ FileType

enum class zrythm::legacy::FileType
strong

File type.

Enumerator
ParentDirectory 

Special entry ".." for the parent dir.

Definition at line 24 of file file_descriptor.h.

◆ UiCursorState

enum class UiCursorState
strong

Various cursor states to be shared.

Definition at line 103 of file ui.h.

◆ UiOverlayAction

enum class UiOverlayAction
strong

Various overlay actions to be shared.

Enumerator
AUTOFILLING 

Auto-filling in edit mode.

Note
This is also used for the pencil tool in velocity and automation editors.
ERASING 

Erasing.

STARTING_MOVING 

To be set in drag_start.

STARTING_SELECTION 

To be set in drag_start.

Useful to check if nothing was clicked.

STARTING_DELETE_SELECTION 

Like selecting but it auto deletes whatever touches the selection.

Definition at line 116 of file ui.h.

Function Documentation

◆ DEFINE_ENUM_FORMATTER()

DEFINE_ENUM_FORMATTER ( UiOverlayAction ,
UiOverlayAction ,
"NONE" ,
"RESIZING_R" ,
"MOVING" ,
"RESIZING_L" ,
"RESIZING_L_LOOP" ,
"RESIZING_L_FADE" ,
"RESIZING_R" ,
"RESIZING_R_LOOP" ,
"RESIZING_R_FADE" ,
"RESIZING_UP" ,
"RESIZING_UP_FADE_IN" ,
"RESIZING_UP_FADE_OUT" ,
"STRETCHING_L" ,
"STRETCHING_R" ,
"STARTING_AUDITIONING" ,
"AUDITIONING" ,
"AUTOFILLING" ,
"ERASING" ,
"STARTING_ERASING" ,
"STARTING_MOVING" ,
"STARTING_MOVING_COPY" ,
"STARTING_MOVING_LINK" ,
"MOVING" ,
"MOVING_COPY" ,
"MOVING_LINK" ,
"STARTING_CHANGING_CURVE" ,
"CHANGING_CURVE" ,
"STARTING_SELECTION" ,
"SELECTING" ,
"STARTING_DELETE_SELECTION" ,
"DELETE_SELECTING" ,
"STARTING_RAMP" ,
"RAMPING" ,
"CUTTING" ,
"RENAMING" ,
"STARTING_PANNING" ,
"PANNING" ,
"--INVALID--"  )

Dragging modes for widgets that have click&drag.

Value is wherever the cursor is.

Value is changed based on the offset.

Value is changed based on the offset, times a multiplier.

Definition at line 184 of file ui.h.

◆ env_get_int()

int env_get_int ( const char * key,
int def )

Returns an int for the given environment variable if it exists and is valid, otherwise returns the default int.

Parameters
defDefault value to return if not found.

◆ iterate_tuple()

template<typename Tuple, typename Callable>
void iterate_tuple ( Callable c,
Tuple && t )

Definition at line 131 of file types.h.

◆ typename_to_string()

template<typename T>
std::string typename_to_string ( )

Definition at line 118 of file types.h.

◆ ui_get_normalized_draggable_value()

double ui_get_normalized_draggable_value ( double size,
double cur_val,
double start_px,
double cur_px,
double last_px,
double multiplier,
UiDragMode mode )

Gets a draggable value as a normalized value between 0 and 1.

Parameters
sizeWidget size (either width or height).
start_pxPx at start of drag.
cur_pxCurrent px.
last_pxPx during last call.

Variable Documentation

◆ UI_COLOR_BRIGHT_GREEN

const char* UI_COLOR_BRIGHT_GREEN = "#1DD169"
constexpr

Definition at line 35 of file ui.h.

◆ UI_COLOR_BRIGHT_ORANGE

const char* UI_COLOR_BRIGHT_ORANGE = "#F79616"
constexpr

Definition at line 39 of file ui.h.

◆ UI_COLOR_BRIGHT_TEXT

const char* UI_COLOR_BRIGHT_TEXT = "#cdcdcd"
constexpr

Definition at line 28 of file ui.h.

◆ UI_COLOR_BUTTON_HOVER

const char* UI_COLOR_BUTTON_HOVER = "#444444"
constexpr

Definition at line 32 of file ui.h.

◆ UI_COLOR_BUTTON_NORMAL

const char* UI_COLOR_BUTTON_NORMAL = "#343434"
constexpr

Definition at line 31 of file ui.h.

◆ UI_COLOR_DARK_ORANGE

const char* UI_COLOR_DARK_ORANGE = "#D68A0C"
constexpr

Definition at line 37 of file ui.h.

◆ UI_COLOR_DARK_TEXT

const char* UI_COLOR_DARK_TEXT = "#323232"
constexpr

Definition at line 27 of file ui.h.

◆ UI_COLOR_DARKISH_GREEN

const char* UI_COLOR_DARKISH_GREEN = "#19664c"
constexpr

Definition at line 36 of file ui.h.

◆ UI_COLOR_FADER_FILL_END

const char* UI_COLOR_FADER_FILL_END = UI_COLOR_Z_YELLOW
constexpr

Definition at line 55 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_BASS_BG

const char* UI_COLOR_HIGHLIGHT_BASS_BG = UI_COLOR_LIGHT_BLUEISH
constexpr

Definition at line 49 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_BASS_FG

const char* UI_COLOR_HIGHLIGHT_BASS_FG = "white"
constexpr

Definition at line 53 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_BOTH_BG

const char* UI_COLOR_HIGHLIGHT_BOTH_BG = "#FF22FF"
constexpr

Definition at line 50 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_BOTH_FG

const char* UI_COLOR_HIGHLIGHT_BOTH_FG = "white"
constexpr

Definition at line 54 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_CHORD_BG

const char* UI_COLOR_HIGHLIGHT_CHORD_BG = "#BB22BB"
constexpr

Definition at line 48 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_CHORD_FG

const char* UI_COLOR_HIGHLIGHT_CHORD_FG = UI_COLOR_HIGHLIGHT_SCALE_FG
constexpr

Definition at line 52 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_SCALE_BG

const char* UI_COLOR_HIGHLIGHT_SCALE_BG = "#662266"
constexpr

Definition at line 47 of file ui.h.

◆ UI_COLOR_HIGHLIGHT_SCALE_FG

const char* UI_COLOR_HIGHLIGHT_SCALE_FG = "#F79616"
constexpr

Definition at line 51 of file ui.h.

◆ UI_COLOR_LIGHT_BLUEISH

const char* UI_COLOR_LIGHT_BLUEISH = "#1aa3ffcc"
constexpr

Definition at line 42 of file ui.h.

◆ UI_COLOR_MATCHA

const char* UI_COLOR_MATCHA = "#2eb398"
constexpr

Definition at line 41 of file ui.h.

◆ UI_COLOR_POSTFADER_SEND

const char* UI_COLOR_POSTFADER_SEND = "#901ed2"
constexpr

Definition at line 44 of file ui.h.

◆ UI_COLOR_PREFADER_SEND

const char* UI_COLOR_PREFADER_SEND = "#D21E6D"
constexpr

Definition at line 43 of file ui.h.

◆ UI_COLOR_PURPLE

const char* UI_COLOR_PURPLE = "#9D3955"
constexpr

Definition at line 30 of file ui.h.

◆ UI_COLOR_RECORD_ACTIVE

const char* UI_COLOR_RECORD_ACTIVE = "#FF2400"
constexpr

Definition at line 34 of file ui.h.

◆ UI_COLOR_RECORD_CHECKED

const char* UI_COLOR_RECORD_CHECKED = "#ED2939"
constexpr

Definition at line 33 of file ui.h.

◆ UI_COLOR_SOLO_ACTIVE

const char* UI_COLOR_SOLO_ACTIVE = UI_COLOR_MATCHA
constexpr

Definition at line 45 of file ui.h.

◆ UI_COLOR_SOLO_CHECKED

const char* UI_COLOR_SOLO_CHECKED = UI_COLOR_DARKISH_GREEN
constexpr

Definition at line 46 of file ui.h.

◆ UI_COLOR_YELLOW

const char* UI_COLOR_YELLOW = "#F9CA1B"
constexpr

Definition at line 29 of file ui.h.

◆ UI_COLOR_Z_PURPLE

const char* UI_COLOR_Z_PURPLE = "#9D3955"
constexpr

Definition at line 40 of file ui.h.

◆ UI_COLOR_Z_YELLOW

const char* UI_COLOR_Z_YELLOW = "#F9CA1B"
constexpr

Definition at line 38 of file ui.h.

◆ UI_DELETE_ICON_NAME

const char* UI_DELETE_ICON_NAME = "z-edit-delete"
constexpr

Definition at line 56 of file ui.h.