Create a music track from a collection of musical phrases.

track(
  phrase,
  clef = "treble_8",
  key = NA,
  tab = TRUE,
  tuning = "standard",
  voice = 1,
  lyrics = NA
)

track_guitar(
  phrase,
  clef = "treble_8",
  key = NA,
  tab = TRUE,
  tuning = "standard",
  voice = 1,
  lyrics = NA
)

track_tc(phrase, key = NA, voice = 1, lyrics = NA)

track_bc(phrase, key = NA, voice = 1, lyrics = NA)

track_bass(phrase, key = NA, voice = 1, lyrics = NA)

Arguments

phrase

a phrase object.

clef

character, include a music staff with the given clef. NA to suppress. See details.

key

character, key signature for music staff. See details.

tab

logical, include tablature staff. NA to suppress.

tuning

character, pitches describing the instrument string tuning or a predefined tuning ID. See tunings(). Defaults to standard guitar tuning; not relevant if tablature staff is suppressed.

voice

integer, ID indicating the unique voice phrase() belongs to within a single track (another track may share the same tab/music staff but have a different voice ID). Up to two voices are supported per track.

lyrics

a lyrics object or NA. See details.

Value

a tibble data frame

Details

Musical phrases generated by phrase() are fortified in a track table. All tracks are stored as track tables, one per row, even if that table consists of a single track. track() creates a single-entry track table. See trackbind() for merging single tracks into a multi-track table. This is row binding that also properly preserves phrase and track classes.

There are various track_* functions offering sensible defaults based on the function suffix. The base track() function is equivalent to track_guitar(). See examples. Setting clef = NA or tab = NA suppresses the music staff or tablature staff, respectively. By default key = NA, in which case its inherits the global key from the key argument of various sheet music rendering functions. If planning to bind two tracks as one where they are given voice = 1 and voice = 2, respectively, they must also have a common key, even if key = NA.

lyrics should only be used for simple tracks that do not contain repeats. You also need to ensure the timesteps for lyrics align with those of phrase() in advance. Additionally, LilyPond does not engrave lyrics at rests or tied notes (excluding first note in tied sequence) so if Therefore, if phrase() contains rests and tied notes then the lyrics object should be subset to exclude these timesteps as well. This is in contrast to using render_music* functions, which handle this automatically for music objects.

See also

Examples

x <- phrase("c ec'g' ec'g'", "4 4 2", "5 4 4")
track(x) # same as track_guitar(x); 8va treble clef above tab staff
#> # A tibble: 1 × 7
#>   phrase       clef     key   tab   tuning    voice lyrics
#>   <list>       <chr>    <chr> <lgl> <chr>     <int> <chr> 
#> 1 <phrase [1]> treble_8 NA    TRUE  e,a,dgbe'     1 NA    
track_tc(x) # treble clef sheet music, no tab staff
#> # A tibble: 1 × 7
#>   phrase       clef   key   tab   tuning    voice lyrics
#>   <list>       <chr>  <chr> <lgl> <chr>     <int> <chr> 
#> 1 <phrase [1]> treble NA    FALSE e,a,dgbe'     1 NA    
track_bc(x) # bass clef sheet music, no tab staff
#> # A tibble: 1 × 7
#>   phrase       clef  key   tab   tuning    voice lyrics
#>   <list>       <chr> <chr> <lgl> <chr>     <int> <chr> 
#> 1 <phrase [1]> bass  NA    FALSE e,a,dgbe'     1 NA    

x <- phrase("c, g,c g,c", "4 4 2", "3 2 2")
track_bass(x) # includes tab staff and standard bass tuning
#> # A tibble: 1 × 7
#>   phrase       clef   key   tab   tuning     voice lyrics
#>   <list>       <chr>  <chr> <lgl> <chr>      <int> <chr> 
#> 1 <phrase [1]> bass_8 NA    FALSE e,,a,,d,g,     1 NA