Helper functions for accessing music object values and attributes.
music_notes(x)
music_info(x)
music_strings(x)
music_key(x)
music_time(x)
music_tempo(x)
music_lyrics(x)
depends on the function
Note that while lyrics always shows as an attribute even when NA
, strings
is completely absent as a value if it was not part of the object construction
from a new character string.
# Starting string = 5: use ';5'. Carries over until an explicit change.
x <- "a,4;5*5 b,4- c4 cgc'e'~4 cgc'e'1 e'4;2 c';3 g;4 c;5 ce'1;51"
x <- as_music(x)
y <- lyrics_template(x)
y[3:8] <- strsplit("These are some song ly- rics", " ")[[1]]
y
#> <Lyrics string>
#> Format: space-delimited time
#> Values: . . These are some song ly- rics . . . . . .
x <- as_music(x, lyrics = y)
attributes(x)
#> $steps
#> [1] 14
#>
#> $n_note
#> [1] 11
#>
#> $n_chord
#> [1] 3
#>
#> $octave
#> [1] "tick"
#>
#> $accidentals
#> [1] "flat"
#>
#> $format
#> [1] "space-delimited time"
#>
#> $key
#> [1] "c"
#>
#> $time
#> [1] "4/4"
#>
#> $tempo
#> [1] "2 = 60"
#>
#> $lyrics
#> <Lyrics string>
#> Format: space-delimited time
#> Values: . . These are some song ly- rics . . . . . .
#>
#> $string
#> [1] "5" "5" "5" "5" "5" "5" "5" "5432" "5432" "2"
#> [11] "3" "4" "5" "51"
#>
#> $class
#> [1] "music" "character"
#>
music_split(x)
#> $notes
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: a, a, a, a, a, b, c <cgc'e'~> <cgc'e'> e' c' g c <ce'>
#>
#> $info
#> <Note info string>
#> Format: space-delimited time
#> Values: 4 4 4 4 4 4- 4 4 1 4 4 4 4 1
#>
#> $string
#> [1] "5" "5" "5" "5" "5" "5" "5" "5432" "5432" "2"
#> [11] "3" "4" "5" "51"
#>
#> $lyrics
#> <Lyrics string>
#> Format: space-delimited time
#> Values: . . These are some song ly- rics . . . . . .
#>
#> $key
#> [1] "c"
#>
#> $time
#> [1] "4/4"
#>
#> $tempo
#> [1] "2 = 60"
#>
music_notes(x)
#> <Noteworthy string>
#> Format: space-delimited time
#> Values: a, a, a, a, a, b, c <cgc'e'~> <cgc'e'> e' c' g c <ce'>
music_info(x)
#> <Note info string>
#> Format: space-delimited time
#> Values: 4 4 4 4 4 4- 4 4 1 4 4 4 4 1
music_key(x)
#> [1] "c"
music_time(x)
#> [1] "4/4"
music_tempo(x)
#> [1] "2 = 60"
music_lyrics(x)
#> <Lyrics string>
#> Format: space-delimited time
#> Values: . . These are some song ly- rics . . . . . .
music_strings(x)
#> [1] "5" "5" "5" "5" "5" "5" "5" "5432" "5432" "2"
#> [11] "3" "4" "5" "51"