|
Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
Thread-safe position storage with automatic musical/absolute time conversion. More...
#include <src/dsp/atomic_position.h>
Data Structures | |
| struct | TimeConversionFunctions |
Public Member Functions | |
| AtomicPosition (const TimeConversionFunctions &conversion_funcs) noexcept | |
| Construct a new AtomicPosition object. | |
| auto | get_current_mode () const |
| Get current storage format (musical ticks or absolute seconds). | |
| void | set_mode (TimeFormat format) |
| Change storage format with automatic value conversion. | |
| void | set_ticks (units::precise_tick_t ticks) |
| Set position in musical ticks. | |
| void | set_seconds (units::precise_second_t seconds) |
| Set position in absolute seconds. | |
| units::precise_tick_t | get_ticks () const |
| Get position in musical ticks (converts if necessary). | |
| units::precise_second_t | get_seconds () const |
| Get position in absolute seconds (converts if necessary). | |
| units::sample_t | get_samples () const |
| Helper method to get the position as samples. | |
| void | set_samples (units::precise_sample_t samples) |
| const auto & | time_conversion_functions () const |
Friends | |
| void | to_json (nlohmann::json &j, const AtomicPosition &pos) |
| void | from_json (const nlohmann::json &j, AtomicPosition &pos) |
Thread-safe position storage with automatic musical/absolute time conversion.
Maintains a position value that can be stored in either:
Automatically converts between formats when the storage mode changes or when accessing in a different format than currently stored. Relies on a TempoMap for conversions between musical and absolute time domains.
Definition at line 76 of file atomic_position.h.
|
inlinenoexcept |
Construct a new AtomicPosition object.
| tempo_map | Reference to tempo map for time conversions. |
Definition at line 120 of file atomic_position.h.
|
inline |
Get current storage format (musical ticks or absolute seconds).
Definition at line 127 of file atomic_position.h.
|
inline |
Helper method to get the position as samples.
Definition at line 221 of file atomic_position.h.
|
inline |
Get position in absolute seconds (converts if necessary).
Definition at line 210 of file atomic_position.h.
|
inline |
Get position in musical ticks (converts if necessary).
Definition at line 199 of file atomic_position.h.
|
inline |
Change storage format with automatic value conversion.
| format | New storage format (TimeFormat::Musical or TimeFormat::Absolute) |
Converts the stored value to match the new format:
Definition at line 144 of file atomic_position.h.
|
inline |
Definition at line 232 of file atomic_position.h.
|
inline |
Set position in absolute seconds.
Converts to ticks if currently in Musical mode.
Definition at line 184 of file atomic_position.h.
|
inline |
Set position in musical ticks.
Converts to seconds if currently in Absolute mode.
Definition at line 165 of file atomic_position.h.
|
inline |
Definition at line 237 of file atomic_position.h.