KaraokeTestudaiBackend/format.py

22 lines
977 B
Python
Raw Permalink Normal View History

2024-12-17 21:14:21 +10:30
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
2024-12-17 21:14:21 +10:30
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
2024-12-17 21:14:21 +10:30
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]:
2024-12-17 21:14:21 +10:30
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]
2024-12-17 21:14:21 +10:30
class LyricTrack:
lines: list[LyricLine]