KaraokeTestudaiBackend/format.py

17 lines
705 B
Python
Raw Normal View History

2024-12-17 21:14:21 +10:30
from collections import namedtuple
# store '{与|あた}えた{使命|しめい} ' as [('与','あた'), ('えた',''), ('使命','しめい'), (' ','')]
FuriBlock = namedtuple('FuriBlock', ['kanji', 'furi'])
class LyricLine:
beat_stamps: list[float] = [] # Start at zero for each line, do real timing via get_timestamps()
translated_line: str
romaji_syllables: list[str] # Allow space entries which will be skipped over when calculating timing
furi_blocks: list[FuriBlock]
def get_timestamps(self, bpm: float, start_offset: float) -> list[float]:
spb = 60.0/bpm # seconds per beat
return [(spb*beat)+start_offset for beat in self.beat_stamps]
class LyricTrack:
lines: list[LyricLine]