lyrics: Create lyrics and check lyrics string validity

lyricsR Documentation

Create lyrics and check lyrics string validity

Description

Functions for creating and checking lyrics objects.

Usage

lyrical(x)

as_lyrics(x, format = NULL)

is_lyrics(x)

lyrics_template(x, format = NULL)

Arguments

x

character or lyrics object. For lyrics_template(), an integer or one of the classes noteworthy, noteinfo or music to derive the number of timesteps from.

format

NULL or character, the timestep delimiter format, "space" or "vector".

Details

The lyrics class is a simple class for arranging lyrics text by timestep. Its structure and behavior aligns with that of the classes noteworthy, noteinfo and music.

lyrical() is a trivial function that returns a scalar logical result essentially for any object that inherits from character, though this check may become more specific in the future.

as_lyrics() can be used to coerce to the lyrics class. Coercion will fail if the string is not lyrical. The lyrics class has its own print() and summary() methods.

When format = NULL, the timestep delimiter format is inferred from the lyrical string input.

Value

depends on the function

Examples

# space-delimited lyrics; use periods for timesteps with no lyric
x <- "These are the ly- rics . . . to this song"
is_lyrics(x)
lyrical(x)
as_lyrics(x)

# character vector; empty, period or NA for no lyric
x <- c("These", "are", "the", "ly-", "rics",
       "", ".", NA, "to", "this", "song") #
as_lyrics(x)

# generate empty lyrics object from noteworthy, noteinfo or music object
notes <- as_noteworthy("c d e d c r*3 e g c'")
x <- lyrics_template(notes)
x

x[1:5] <- strsplit("These are the ly- rics", " ")[[1]]
x[9:11] <- c("to", "this", "song")
x

summary(x)

attributes(x)

tabr documentation built on Sept. 12, 2024, 6:18 a.m.