Creating scales with tabr and Lilypond

Han Oostdijk

2019/12/16

Date last run: 05Jan2020

To make it easier to ‘code’ musical scores with tabr and Lilypond I have printed the treble and bass scales with the codes of the notes. Remember that guitar music is written one octave higher than it sounds!

library(tabr)

notes1 <- "e2 f2 g2 a2 b2 c3 d3 e3 f3 g3 a3 b3 c4 d4 e4 f4 g4 a4 b4 c5 d5 e5 f5 g5"
times1 <- "4*24"
lyrics1 <- strsplit(notes1," ")[[1]] 
voice1  <- p(notes1,times1,string=NULL) 
voice1  <- p(notes1,times1,string=NULL)
track1 <- track(voice1, voice = 1,tab=F,lyrics=as_lyrics(lyrics1))

notes2 <- "a1 b1 c2 d2 e2 f2 g2 a2 b2 c3 d3 e3 f3 g3 a3 b3 c4 d4 e4 f4 g4 a4 b4 c5" 
times2 <- "4*24"
lyrics2 <- strsplit(notes2," ")[[1]] 
voice2  <- p(notes2,times2,string=NULL)
track2 <- track_bc(voice2, voice = 2,lyrics=as_lyrics(lyrics2))
track3 <- track(voice2, voice = 3,tab=F,lyrics=as_lyrics(lyrics2))
track4 <- track_tc(voice1, voice = 4,lyrics=as_lyrics(lyrics1))

song <- trackbind(track1,track2) %>% score()

header <- list(title="Scales",
               tagline="")
paper <- list(first_page_number =4,page_numbers=T,print_first_page_number=F,
              textheight = 35,linewidth = 120)
filename = "opus1"
filetype = "png" 

With the following statement we produce the file opus1.png :

tab(song, glue::glue("{filename}.{filetype}"), key="c", time="4/4",
    tempo=NULL,string_names=T,header=header,paper=paper,
    midi=F,keep_ly=F,details=F)

The resulting file opus1.png looks like:

Session Info

This document was produced on 05Jan2020 with the following R environment:

  #> R version 3.6.0 (2019-04-26)
  #> Platform: x86_64-w64-mingw32/x64 (64-bit)
  #> Running under: Windows 10 x64 (build 18362)
  #> 
  #> Matrix products: default
  #> 
  #> locale:
  #> [1] LC_COLLATE=English_United States.1252 
  #> [2] LC_CTYPE=English_United States.1252   
  #> [3] LC_MONETARY=English_United States.1252
  #> [4] LC_NUMERIC=C                          
  #> [5] LC_TIME=English_United States.1252    
  #> 
  #> attached base packages:
  #> [1] stats     graphics  grDevices utils     datasets  methods   base     
  #> 
  #> other attached packages:
  #> [1] tabr_0.4.1
  #> 
  #> loaded via a namespace (and not attached):
  #>  [1] Rcpp_1.0.3       crayon_1.3.4     dplyr_0.8.3      assertthat_0.2.1
  #>  [5] R6_2.4.1         magrittr_1.5     evaluate_0.14    pillar_1.4.3    
  #>  [9] rlang_0.4.2      stringi_1.4.3    fs_1.3.1         tools_3.6.0     
  #> [13] stringr_1.4.0    glue_1.3.1       purrr_0.3.3      xfun_0.10       
  #> [17] compiler_3.6.0   pkgconfig_2.0.3  tidyselect_0.2.5 knitr_1.26      
  #> [21] tibble_2.1.3