Bind together track tables by row.

trackbind(..., id)

Arguments

...

single-entry track data frames.

id

integer, ID vector indicating distinct tracks corresponding to distinct sheet music staves. See details.

Value

a tibble data frame

Details

This function appends multiple track tables into a single track table for preparation of generating a multi-track score. id is used to separate staves in the sheet music/tablature output. A track's voice is used to separate distinct voices within a common music staff.

If not provided, id automatically propagates 1:n for n tracks passed to ... when binding these tracks together. This expresses the default assumption of one staff or music/tab staff pair per track. This is the typical use case.

Some tracks represent different voices that share the same staff. These should be assigned the same id, in which case you must provide the id argument. Up to two voices per track are supported. An error will be thrown if any two tracks have both the same voice and the same id. The pair must be unique. E.g., provide id = c(1, 1) when you have two tracks with voice equal to 1 and 2. See examples.

Note that the actual ID values assigned to each track do not matter; only the order in which tracks are bound, first to last.

See also

Examples

x <- phrase("c ec'g' ec'g'", "4 4 2", "5 432 432")
x1 <- track(x)
x2 <- track(x, voice = 2)
trackbind(x1, x1)
#> # A tibble: 2 × 8
#>   phrase       clef     key   tab   tuning    voice lyrics    id
#>   <list>       <chr>    <chr> <lgl> <chr>     <int> <chr>  <int>
#> 1 <phrase [1]> treble_8 NA    TRUE  e,a,dgbe'     1 NA         1
#> 2 <phrase [1]> treble_8 NA    TRUE  e,a,dgbe'     1 NA         2
trackbind(x1, x2, id = c(1, 1))
#> # A tibble: 2 × 8
#>   phrase       clef     key   tab   tuning    voice lyrics    id
#>   <list>       <chr>    <chr> <lgl> <chr>     <int> <chr>  <int>
#> 1 <phrase [1]> treble_8 NA    TRUE  e,a,dgbe'     1 NA         1
#> 2 <phrase [1]> treble_8 NA    TRUE  e,a,dgbe'     2 NA         1