plot_music {tabr} | R Documentation |
Plot sheet music snippet with LilyPond
Description
These functions are wrappers around the render_music*
functions. They
abstract the process of rendering a sheet music snippet to png and loading
the rendered image back into R to be displayed as a plot in an open graphics
device or inserted into an R Markdown code chunk.
Usage
plot_music(
music,
clef = "treble",
tab = FALSE,
tuning = "standard",
string_names = NULL,
header = NULL,
paper = NULL,
colors = NULL,
transparent = FALSE,
res = 300
)
plot_music_tc(
music,
header = NULL,
paper = NULL,
colors = NULL,
transparent = FALSE,
res = 300
)
plot_music_bc(
music,
header = NULL,
paper = NULL,
colors = NULL,
transparent = FALSE,
res = 300
)
plot_music_tab(
music,
clef = NA,
tuning = "standard",
string_names = NULL,
header = NULL,
paper = NULL,
colors = NULL,
transparent = FALSE,
res = 300
)
plot_music_guitar(
music,
tuning = "standard",
string_names = NULL,
header = NULL,
paper = NULL,
colors = NULL,
transparent = FALSE,
res = 300
)
plot_music_bass(
music,
tuning = "bass",
string_names = FALSE,
header = NULL,
paper = NULL,
colors = NULL,
transparent = FALSE,
res = 300
)
Arguments
music |
a music object. |
clef |
character, include a music staff with the given clef. |
tab |
logical, include tablature staff. |
tuning |
character, string tuning, only applies to tablature. See
|
string_names |
label strings at beginning of tab staff. |
header |
a named list of arguments passed to the header of the LilyPond
file. See |
paper |
a named list of arguments for the LilyPond file page layout. See
|
colors |
a named list of LilyPond element color global overrides. See
|
transparent |
logical, transparent background for intermediate png file. |
res |
numeric, resolution, png only. Defaults to 300. |
Details
While these functions abstract away the details of the process, this is not the same as making the plot completely in R. R is only displaying the intermediary png file. LilyPond is required to engrave the sheet music.
For R Markdown you can alternatively render the png using the corresponding
render_music*
function and then place it in the document explicitly
using knitr::include_graphics()
. See render_music()
for more details.
Value
a plot
See Also
render_music()
, phrase()
, track()
, score()
, lilypond()
,
tab()
Examples
x <- "a,4;5*5 b,4- c4 cgc'e'~4 cgc'e'1 e'4;2 c';3 g;4 c;5 ce'1;51"
x <- as_music(x)
y <- "a,,4;3*5 b,,4- c,4 c,g,c~4 c,g,c1 c4;1 g,;2 c,;3 g,;2 c,c1;31"
y <- as_music(y)
## Not run:
if(tabr_options()$lilypond != ""){ # requires LilyPond installation
plot_music(x)
plot_music(x, "treble_8", tab = TRUE)
plot_music_tc(x)
plot_music_bc(x)
plot_music_tab(x)
plot_music_guitar(x)
plot_music_bass(y)
}
## End(Not run)