Add schedule sync and schedule-aware playback

This commit is contained in:
NeilClack
2026-09-11 19:14:55 -05:00
parent a043ec84d8
commit f37beaf07e
23 changed files with 893 additions and 32 deletions
+22
View File
@@ -1,5 +1,6 @@
#pragma once
#include "db/database_manager.h"
#include "fibonacci_line_pattern.h"
#include "page.h"
#include "scroller_streams.h"
@@ -82,6 +83,16 @@ private:
bool addLineAt(float baseY);
void advanceStream();
void switchAudioForCurrentStream();
// Re-reads the schedule from the DB/config and records which block (if any)
// matches the clock right now. Returns the matching index, or -1.
int currentScheduleBlockIndex() const;
// If the active block changed, latch a pending switch that is applied at the
// next proclamation boundary so the current proclamation is never cut off.
void pollScheduleChange();
// True when the current stream should use dynamic (frequency-following)
// audio. A schedule block with dynamicAudio=true forces it on; otherwise the
// configured audio.dynamic_audio setting applies.
bool effectiveDynamicAudio() const;
void updateAutoVelocity(float dt);
void ensureWordTexture(const std::string& word);
void ensureCharTexture(const std::string& glyph);
@@ -97,6 +108,17 @@ private:
int streamIndex_ = 0;
bool prefilling_ = false;
// Schedule playback. `scheduleActive_` mirrors config; `scheduleBlocks_` is
// the cached schedule; `activeBlockIndex_` is the block currently playing
// (-1 = normal mode / no matching block). A change is latched in
// `scheduleChangePending_` and applied when the current proclamation ends.
std::string timezone_;
std::vector<radiantwave::db::ScheduleBlockRecord> scheduleBlocks_;
bool scheduleActive_ = false;
int activeBlockIndex_ = -1;
bool scheduleChangePending_ = false;
float schedulePollTimer_ = 0.0f;
TTF_Font* font_ = nullptr;
int fontPxSize_ = 32;
float lineHeight_ = 0;