Convert a MIDI file (.mid) to a LilyPond format (.ly) text file.

midily(
  midi_file,
  file,
  key = "c",
  absolute = FALSE,
  quantize = NULL,
  explicit = FALSE,
  start_quant = NULL,
  allow_tuplet = c("4*2/3", "8*2/3", "16*2/3"),
  details = FALSE,
  lyric = FALSE
)

Arguments

midi_file

character, MIDI file (.mid). May include an absolute or relative path.

file

LilyPond output file ending in .ly.

key

key signature, defaults to "c".

absolute

logical, print absolute pitches (unavailable in current package version).

quantize

integer, duration, quantize notes on duration.

explicit

logical, print explicit durations.

start_quant

integer, duration, quantize note starts on the duration.

allow_tuplet

character vector, allow tuplet durations. See details.

details

logical, print additional information to console.

lyric

logical, treat all text as lyrics.

Value

nothing returned; a file is written.

Details

Under development/testing. See warning and details below.

This function is a wrapper around the midi2ly() command line utility provided by LilyPond. It inherits all the limitations thereof. LilyPond is not intended to be used to produce meaningful sheet music from arbitrary MIDI files. While lilypond() converts R code score() objects to LilyPond markup directly, MIDI conversion to LilyPond markup by midily() requires LilyPond.

WARNING: Even though the purpose of the command line utility is to convert an existing MIDI file to a LilyPond file, it nevertheless generates a LilyPond file that specifies inclusion of MIDI output. This means when you subsequently process the LilyPond file with LilyPond or if you use miditab() to go straight from your MIDI file to pdf output, the command line tool will also produce a MIDI file output. It will overwrite your original MIDI file if it has the same file name and location!

allow_tuplets = NULL to disallow all tuplets. Fourth, eighth and sixteenth note triplets are allowed. The format is a character vector where each element is duration*numerator/denominator, no spaces. See default argument.

On Windows systems, it may be necessary to specify a path in tabr_options() to both midi2ly and python if they are not already added to the system PATH variable.

Examples

if (FALSE) { # \dontrun{
if(tabr_options()$midi2ly != ""){
  midi <- system.file("example.mid", package = "tabr")
  outfile <- file.path(tempdir(), "out.ly")
  midily(midi, outfile) # requires LilyPond installation
}
} # }