95 std::array<TransportRange, 2>
ranges{};
156static_assert(std::is_trivially_copyable_v<TransportPlayhead>);
157static_assert(std::is_trivially_copyable_v<TransportLoopState>);
168 std::uint32_t output_offset)
noexcept;
175 std::uint32_t& output_offset)
noexcept;
262 const auto desired = desired_.read();
264 .sequence = desired.loop_sequence, .loop = desired.loop, .prepared = desired.prepared};
270 struct BlockProjection;
271 struct RangeProjection;
272 struct DesiredState {
277 std::uint32_t scrub_window_frames = 0;
278 bool playing =
false;
279 bool scrubbing =
false;
280 bool prepared =
false;
281 std::uint64_t loop_sequence = 0;
282 std::uint64_t seek_generation = 0;
283 std::uint64_t scrub_generation = 0;
284 std::uint64_t playing_generation = 0;
285 std::uint64_t tempo_sync_tempo_generation = 0;
286 double tempo_sync_tempo_bpm = 120.0;
289 static_assert(std::is_trivially_copyable_v<DesiredState>);
292 void publish_desired() noexcept;
296 std::int64_t output_host_time_micros,
298 void begin_projected_block(const DesiredState& desired, const BlockProjection& projection,
301 void append_projected_range(const RangeProjection& projection,
303 void finish_projected_block(const DesiredState& desired, const BlockProjection& projection,
310 runtime::SeqLock<DesiredState> desired_{};
312 std::uint64_t loop_sequence_ = 0;
313 std::uint64_t playhead_sequence_ = 0;
314 DesiredState control_state_{};
315 const timebase::CompiledTempoMap* tempo_map_ =
nullptr;
316 timebase::TempoCursor tempo_cursor_{};
317 TempoSyncSource* tempo_sync_source_ =
nullptr;
318 double tempo_sync_quantum_beats_ = 4.0;
319 std::uint32_t max_buffer_size_ = 0;
321 timebase::SamplePosition timeline_sample_{};
322 timebase::TickPosition timeline_tick_{};
323 timebase::MonotonicBeat monotonic_{};
324 timebase::TickPosition meter_anchor_tick_{};
325 timebase::BarPosition meter_anchor_bar_{};
327 std::uint64_t applied_seek_generation_ = 0;
328 std::uint64_t applied_scrub_generation_ = 0;
329 std::uint64_t applied_tempo_sync_playing_generation_ = 0;
330 std::uint64_t applied_tempo_sync_seek_generation_ = 0;
331 std::uint64_t applied_tempo_sync_tempo_generation_ = 0;
332 std::uint64_t block_index_ = 0;
333 std::uint64_t playback_epoch_ = 0;
334 bool playback_epoch_exhausted_ =
false;
335 std::uint64_t loop_pass_index_ = 0;
336 std::uint32_t scrub_window_remaining_ = 0;
337 bool previous_scrubbing_ =
false;
338 bool has_applied_scrub_position_ =
false;
339 timebase::TickPosition applied_scrub_position_{};
340 bool previous_playing_ =
false;
343 double previous_tempo_bpm_ = 120.0;
344 bool first_block_ =
true;
345 bool pending_discontinuity_ =
false;
346 bool has_expected_tempo_sync_beat_ =
false;
347 double expected_tempo_sync_beat_ = 0.0;
static constexpr audio::RtSafetyClass begin_block_rt_safety_class
Definition transport.hpp:199
TransportError scrub_to(timebase::TickPosition position) noexcept
Moves the scrub anchor. Fails with NotScrubbing outside scrub mode.
TransportLoopState loop_state() const noexcept
The latest accepted loop state, including edits not yet consumed by an audio block.
Definition transport.hpp:261
TransportError set_loop(LoopRegion loop) noexcept
TransportError set_playing(bool playing) noexcept
TransportError begin_scrub(std::uint32_t window_frames, timebase::TickPosition position) noexcept
Enters scrub mode: the transport renders repeated window_frames-long windows that each start at the l...
TransportError begin_block(std::uint32_t frame_count, TransportSnapshot &snapshot) noexcept
TransportError set_tempo_sync_tempo(double tempo_bpm) noexcept
Publishes an explicit session-tempo request.
TransportError set_meter(MeterSignature meter) noexcept
MasterTransport()=default
TransportError prepare(const timebase::CompiledTempoMap &tempo_map, const MasterTransportConfig &config) noexcept
tempo_map must outlive this transport or the next reset()/prepare().
TransportPlayhead playhead() const noexcept
The latest published playhead reading, by value.
Definition transport.hpp:255
TransportError seek(timebase::TickPosition position) noexcept
TransportError end_scrub() noexcept
Leaves scrub mode and parks the playhead on the last posted anchor — where the drag was released — ne...
Opaque host-clock timestamp produced by the TempoSyncSource that owns the corresponding clock domain.
Definition tempo_sync.hpp:16
Backend-neutral session-tempo boundary.
Definition tempo_sync.hpp:106
Lock-free reader/writer for reading multi-field structs as consistent snapshots.
Definition seqlock.hpp:42
Definition compiled_tempo_map.hpp:91
RtSafetyClass
Definition rt_safety_contract.hpp:11
@ AudioCallbackSafeAfterPrepare
Definition rt_safety_contract.hpp:13
TransportError advance_playback_epoch(std::uint64_t &epoch) noexcept
Advances an epoch without ever wrapping to an aliased identity.
Definition audio_renderer.hpp:20
long double host_mapped_document_sample_at_output_offset(const TransportRange &range, const timebase::CompiledTempoMap &tempo_map, std::uint32_t output_offset) noexcept
Maps an output-frame boundary in a host-beat-mapped range back into the program's document-sample dom...
@ NotPrepared
Definition automation_recording.hpp:30
@ None
Definition automation_recording.hpp:29
bool valid_transport_ranges(const TransportSnapshot &transport) noexcept
Validates the shared structural contract consumed by every block renderer.
timebase::LoopRegion LoopRegion
The loop is a pair of document positions, so the timebase owns it and every rung that describes a loo...
Definition transport.hpp:43
TransportError
Definition transport.hpp:16
@ InvalidTempoSyncState
Definition transport.hpp:30
@ LoopTooShortForMaximumBlock
Definition transport.hpp:21
@ TempoSyncUnavailable
Definition transport.hpp:29
@ InvalidTempoSyncConfig
Definition transport.hpp:27
@ InvalidLoop
Definition transport.hpp:20
@ TempoSyncHostTimeRequired
Definition transport.hpp:28
@ InvalidScrubWindow
Definition transport.hpp:23
@ InvalidFrameCount
Definition transport.hpp:22
@ NotScrubbing
Definition transport.hpp:25
@ InvalidMeter
Definition transport.hpp:19
@ ScrubWindowTooShortForMaximumBlock
Definition transport.hpp:24
@ InvalidTempo
Definition transport.hpp:26
@ PlaybackEpochExhausted
Definition transport.hpp:31
timebase::MeterSignature MeterSignature
Definition transport.hpp:39
bool host_mapped_output_offset_for_tick(const TransportRange &range, timebase::TickPosition document_tick, std::uint32_t &output_offset) noexcept
Maps an exact program event tick into a half-open host-beat-mapped transport range.
Definition generated_event_source.hpp:33
Definition beat_division.hpp:11
Lock-free sequence-lock for coherent multi-field snapshots.
Definition transport.hpp:177
bool initially_playing
Definition transport.hpp:182
double tempo_sync_quantum_beats
Definition transport.hpp:187
timebase::TickPosition initial_position
Definition transport.hpp:181
TempoSyncSource * tempo_sync_source
Optional non-owning session-tempo source.
Definition transport.hpp:186
std::uint32_t max_buffer_size
Definition transport.hpp:178
MeterSignature meter
Definition transport.hpp:179
LoopRegion loop
Definition transport.hpp:180
The transport's accepted loop control state.
Definition transport.hpp:148
constexpr bool operator==(const TransportLoopState &) const =default
std::uint64_t sequence
Definition transport.hpp:149
bool prepared
Definition transport.hpp:151
LoopRegion loop
Definition transport.hpp:150
Where the transport is, published for a reader that is not the audio thread.
Definition transport.hpp:115
double tempo_bpm
Definition transport.hpp:132
std::uint64_t sequence
Monotonic per publish.
Definition transport.hpp:121
timebase::TickPosition position
Position of the FIRST frame of the published block.
Definition transport.hpp:130
bool scrubbing
Definition transport.hpp:137
std::uint64_t playback_epoch
Identity of the continuous playback interval this reading belongs to.
Definition transport.hpp:125
constexpr bool operator==(const TransportPlayhead &) const =default
bool is_playing
True whenever the position advances on its own.
Definition transport.hpp:136
LoopRegion loop
Definition transport.hpp:131
Definition transport.hpp:45
timebase::TickPosition timeline_tick_end
Definition transport.hpp:50
std::uint32_t sample_offset
Definition transport.hpp:46
std::uint32_t frame_count
Definition transport.hpp:47
std::uint64_t playback_epoch
Identity of the continuous playback interval containing this range.
Definition transport.hpp:64
bool tempo_changed
Definition transport.hpp:55
double host_tick_start
Definition transport.hpp:58
double host_tick_end
Definition transport.hpp:59
timebase::TickPosition timeline_tick_start
Definition transport.hpp:49
double tempo_bpm
Definition transport.hpp:54
timebase::SamplePosition timeline_sample_start
Definition transport.hpp:48
bool host_beat_mapping
Definition transport.hpp:57
timebase::MonotonicBeat monotonic_end
Definition transport.hpp:52
timebase::BarPosition bar_start
Definition transport.hpp:53
std::uint64_t loop_pass_index
Zero-based loop pass within the transport's current playback epoch.
Definition transport.hpp:68
timebase::MonotonicBeat monotonic_start
Definition transport.hpp:51
bool discontinuity
Definition transport.hpp:56
bool has_precise_host_ticks
Definition transport.hpp:60
Definition transport.hpp:71
bool scrubbing
True while the transport is rendering scrub windows.
Definition transport.hpp:88
double host_loop_end_beats
Definition transport.hpp:98
LoopRegion loop
Definition transport.hpp:82
std::array< TransportRange, 2 > ranges
Definition transport.hpp:95
bool transport_changed
Definition transport.hpp:89
bool time_sig_changed
Definition transport.hpp:92
double host_loop_start_beats
Definition transport.hpp:97
bool reset_requested
Definition transport.hpp:91
std::uint64_t block_index
Definition transport.hpp:76
MeterSignature meter
Definition transport.hpp:81
timebase::RationalRate sample_rate
Definition transport.hpp:75
std::uint32_t frame_count
Definition transport.hpp:80
std::uint8_t range_count
Definition transport.hpp:96
bool has_precise_host_loop
Definition transport.hpp:99
const timebase::CompiledTempoMap * tempo_map
Non-owning identity of the exact compiled map used to resolve ranges.
Definition transport.hpp:74
double tempo_bpm
Convenience mirror of ranges[0].tempo_bpm for block-level consumers.
Definition transport.hpp:94
bool is_playing
Definition transport.hpp:83
bool transport_started
Definition transport.hpp:90
std::uint64_t playback_epoch
Epoch of ranges[0].
Definition transport.hpp:79
Definition compiled_meter_map.hpp:26
The loop bounds a transport honours, in document ticks.
Definition loop_region.hpp:20
Definition compiled_meter_map.hpp:14
Definition rational_time.hpp:14
Definition rational_time.hpp:9