track: Create a music track

View source: R/tracks.R

trackR Documentation

Create a music track

Description

Create a music track from a collection of musical phrases.

Usage

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.

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.

Value

a tibble data frame

See Also

phrase(), score()

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
track_tc(x) # treble clef sheet music, no tab staff
track_bc(x) # bass clef sheet music, no tab staff

x <- phrase("c, g,c g,c", "4 4 2", "3 2 2")
track_bass(x) # includes tab staff and standard bass tuning

tabr documentation built on Sept. 21, 2023, 5:06 p.m.