read_midi | R Documentation |
Read MIDI file into a data frame and inspect the music data with supporting functions.
read_midi(file, ticks_per_qtr = 480)
midi_metadata(x)
midi_notes(x, channel = NULL, track = NULL, noteworthy = TRUE)
midi_time(x)
midi_key(x)
ticks_to_duration(x, ticks_per_qtr = 480)
duration_to_ticks(x, ticks_per_qtr = 480)
file |
character, path to MIDI file. |
ticks_per_qtr |
ticks per quarter note. Used to compute durations from MIDI file ticks. |
x |
a data frame returned by |
channel , track |
integer, filter rows on channel or track. |
noteworthy |
logical, convert to |
The read_midi()
function wraps around tuneR::readMidi()
by Uwe Ligges and
Johanna Mielke. midi_notes()
is a work in progress, but converts MIDI data
to noteworthy strings and note info formats. This makes it easy to analyze,
transform and edit the music data as well as render it to sheet music and a
new MIDI file.
read_midi()
does not parse the ticks per quarter note from the MIDI file
input at this time. It must be specified with ticks_per_qtr
.
a tibble data frame
ticks_to_duration(c(120, 160))
ticks_to_duration(c(128, 192, 512), ticks_per_qtr = 384)
duration_to_ticks(c("t8", "8", "8.", "8.."))
duration_to_ticks(c("t8 8 8. 8.."), ticks_per_qtr = 384)
file <- system.file("example2.mid", package = "tabr")
if(require("tuneR")){
x <- read_midi(file, ticks_per_qtr = 384)
midi_metadata(x)
midi_time(x)
midi_key(x)
midi_notes(x, channel = 0, noteworthy = FALSE)
(x <- midi_notes(x, channel = 0))
(x <- as_music(x$pitch, x$duration))
# requires LilyPond installation
if(tabr_options()$lilypond != ""){
out <- file.path(tempdir(), "out.pdf")
phrase(x) |> track_bc() |> score() |> tab(out, details = FALSE)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.