KaraokeTestudaiBackend/format.py

22 lines
977 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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