Files
radiantwave/src/scroller_streams.h
T
2026-08-07 14:51:41 -05:00

56 lines
2.0 KiB
C++

#pragma once
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>
namespace radiantwave::db {
struct ProclamationRecord;
struct AudioFileRecord;
}
namespace radiantwave::scroller {
// A single color in an RGBA palette (independent of the DB layer).
struct StreamColor {
uint8_t r = 0;
uint8_t g = 0;
uint8_t b = 0;
uint8_t a = 255;
};
// Full passes each user-selected proclamation plays before the default is
// shown, and vice versa. Adjust here to tune how long each text stays up.
inline constexpr int kSelectedRepeatCount = 20;
inline constexpr int kDefaultRepeatCount = 10;
struct ProclamationStream {
std::string name;
std::vector<std::string> words;
int repeat = 1; // full passes before the stream advances
int completed = 0; // passes fully consumed so far
int wordsPlaced = 0; // words consumed in the current partial pass
std::vector<StreamColor> palette;
int colorIndex = 0; // next palette color to apply to a line
int solfeggio_frequency_id = 0;
std::string audioFilename; // empty = never touch audio
};
// Builds the ordered stream list by interleaving the selected proclamations
// with the default: each selected proclamation (in database order) plays
// `kSelectedRepeatCount` passes, then the default plays `kDefaultRepeatCount`
// passes, then the next selected proclamation, and so on. The first
// user-selected proclamation always plays first. If nothing is selected, only
// the default plays. `palettesByFreqId` and `audioByFreqId` are
// database-derived lookups; `fallbackPalette` is used for the default stream
// and unknown frequencies.
std::vector<ProclamationStream> buildStreams(
const std::vector<db::ProclamationRecord>& proclamations,
const std::unordered_map<int, std::vector<StreamColor>>& palettesByFreqId,
const std::vector<StreamColor>& fallbackPalette,
const std::unordered_map<int, db::AudioFileRecord>& audioByFreqId,
const std::string& defaultProclamationId);
} // namespace radiantwave::scroller