Skip to content

Quickstart

From a lyrics file to lines that light up word by word, in three steps.

Hand the text to detectParser. It tells TTML, LRC, SRT and QRC apart, and reads anything else as plain lines, one lyric per line of text.

import dev.kiyoshi.braccato.parsers.detectParser
val parser = detectParser(text)
val lyrics = parser.parse(text, songDurationMs)
val songwriters = parser.metadata(text).songwriters

The song’s duration, in milliseconds, lets the parser add an instrumental line for the outro. Read the file once when the lyrics arrive, not on every frame.

Building splits each line into words, groups and background vocals, and works out which way it reads. Do it when the song changes:

import dev.kiyoshi.braccato.core.SetLyricsOptions
import dev.kiyoshi.braccato.core.buildLyrics
val built = remember(lyrics) { buildLyrics(lyrics, SetLyricsOptions(songwriters = songwriters)) }

The songwriters, when there are any, are shown after the last line.

import dev.kiyoshi.braccato.compose.BraccatoLyrics
import dev.kiyoshi.braccato.compose.PlaybackSnapshot
BraccatoLyrics(
lyrics = built,
playback = { PlaybackSnapshot(timeS = player.positionS, isPlaying = player.isPlaying) },
onSeek = { player.seekTo(it) },
)

playback is read once per frame, so a player’s position can be handed over as it is. onSeek is called with a time in seconds when a line is tapped; leave it out and the lines stay inert.

  • Scrolling Lyrics: what it draws, and what the user’s own scrolling does
  • Theming: colours, sizes, fonts and which effects run