render_chordchart: Render a chord chart with LilyPond

View source: R/lp_render.R

render_chordchartR Documentation

Render a chord chart with LilyPond

Description

Render a standalone chord chart of chord fretboard diagrams with LilyPond for a set of chords.

Usage

render_chordchart(
  chords,
  file,
  size = 1.2,
  header = NULL,
  paper = NULL,
  colors = NULL,
  crop_png = TRUE,
  transparent = FALSE,
  res = 150,
  keep_ly = FALSE,
  details = FALSE
)

Arguments

chords

named character vector of valid formatting for LilyPond chord names and values. See examples.

file

output file.

size

numeric, size of fretboard diagrams (relative to paper font size). Use this to scale diagrams up or down.

header

a named list of arguments passed to the header of the LilyPond file. See details.

paper

a named list of arguments for the LilyPond file page layout. See details.

colors

reserved; not yet implemented for this function.

crop_png

logical, see lilypond() for details.

transparent

logical, transparent background, png only.

res

numeric, resolution, png only. transparent = TRUE may fail when res exceeds ~150.

keep_ly

logical, keep intermediate LilyPond file.

details

logical, set to TRUE to print LilyPond log output to console. Windows only.

Details

This function uses a generates a LilyPond template for displaying only a fretboard diagram chart. It then passes the file to LilyPond for rendering. To plot specific fretboard diagrams in R using ggplot and with greater control, use plot_fretboard().

The options for paper include the following and have the following default values if not provided.

  • textheight = 220

  • linewidth = 150

  • indent = 0

  • fontsize = 10

  • page_numbers = FALSE

  • print_first_page_number = TRUE

  • first_page_number = 1

fontsize only controls the global font size. If you want to scale the size of the fretboard diagrams up or down use the the size argument rather than this paper value.

Note that chord chart output must fit on a single page. If the full set of chord diagrams does not fit on one page then diagrams will be clipped in the rendered output. Use size to keep the output to one page or make multiple sheets separately.

Value

writes files to disk

See Also

plot_fretboard(), lilypond(), tab()

Examples

suppressPackageStartupMessages(library(dplyr))

chords <- filter(
  guitarChords, root %in% c("c", "f") & id %in% c("7", "M7", "m7") &
  !grepl("#", notes) & root_fret <= 12) |>
  arrange(root, id)
chords <- setNames(chords$fretboard, chords$lp_name)
head(chords)

# requires LilyPond installation
if(tabr_options()$lilypond != ""){
  outfile <- file.path(tempdir(), "out.pdf")
  hdr <- list(
    title = "Dominant 7th, major 7th and minor 7th chords",
    subtitle = "C and F root"
  )
  render_chordchart(chords, outfile, 2, hdr, list(textheight = 175))
}

tabr documentation built on Sept. 12, 2024, 6:18 a.m.