Provides thread-safe playhead positioning with sample-accurate timing.
More...
#include <src/dsp/playhead.h>
Provides thread-safe playhead positioning with sample-accurate timing.
The Playhead class maintains synchronized position information in both samples (for audio processing) and ticks (for musical operations). It guarantees real-time safety for audio threads while allowing GUI updates.
Definition at line 62 of file playhead.h.
◆ Playhead()
| zrythm::dsp::Playhead::Playhead |
( |
const TempoMap & | tempo_map | ) |
|
|
inline |
Construct a Playhead associated with a TempoMap.
- Parameters
-
| tempo_map | Reference to project's TempoMap |
Definition at line 71 of file playhead.h.
◆ advance_processing()
| void zrythm::dsp::Playhead::advance_processing |
( |
units::sample_t | nframes | ) |
|
|
inlinenoexcept |
Advance processing position (audio thread safe).
- Parameters
-
| nframes | Number of frames advanced (negative for backwards, eg when looping back) |
- Warning
- Must only be called from the system audio callback thread.
Definition at line 99 of file playhead.h.
◆ get_tempo_map()
| const auto & zrythm::dsp::Playhead::get_tempo_map |
( |
| ) |
const |
|
inline |
◆ position_during_processing_precise()
| auto zrythm::dsp::Playhead::position_during_processing_precise |
( |
| ) |
const |
|
inlinenoexcept |
Get current position during processing (audio thread safe).
- Returns
- Position in samples as double
- Note
- Can be called concurrently from multiple audio threads
Definition at line 119 of file playhead.h.
◆ position_during_processing_rounded()
| units::sample_t zrythm::dsp::Playhead::position_during_processing_rounded |
( |
| ) |
const |
|
inlinenoexcept |
◆ position_samples_FOR_TESTING()
| auto zrythm::dsp::Playhead::position_samples_FOR_TESTING |
( |
| ) |
const |
|
inlinenoexcept |
Get current playhead position in samples (non-RT).
- Note
- For testing and debugging only
Definition at line 200 of file playhead.h.
◆ position_ticks()
| auto zrythm::dsp::Playhead::position_ticks |
( |
| ) |
const |
|
inline |
Get current playhead position in ticks (GUI thread only).
- Returns
- Position in ticks
Definition at line 173 of file playhead.h.
◆ set_position_ticks()
| void zrythm::dsp::Playhead::set_position_ticks |
( |
units::precise_tick_t | ticks | ) |
|
|
inline |
Set playhead position in musical ticks (GUI thread only).
- Parameters
-
| ticks | New position in ticks |
- Note
- Uses mutex to synchronize with GUI thread
Definition at line 161 of file playhead.h.
◆ update_ticks_from_samples()
| void zrythm::dsp::Playhead::update_ticks_from_samples |
( |
| ) |
|
|
inline |
Update tick position from sample position.
To be called periodically as part of the GUI event loop to synchronize positions
Definition at line 187 of file playhead.h.
◆ from_json
| void from_json |
( |
const nlohmann::json & | j, |
|
|
Playhead & | pos ) |
|
friend |
◆ PlayheadProcessingGuard
| friend class PlayheadProcessingGuard |
|
friend |
◆ to_json
| void to_json |
( |
nlohmann::json & | j, |
|
|
const Playhead & | pos ) |
|
friend |
The documentation for this class was generated from the following file: