player | R Documentation |
Play midi from MidiFramer object. Helper function to synthesize midi, either:
directly in the console,
or generate audio files and include a small player in html documents.
This helper function is also called in the MidiFramer$play()
method.
WARNING: Setting overwrite = TRUE
(the default!!) will DELETE the specified audio files!!!
(see more details below)
player(
midifile,
soundfont = fluidsynth::soundfont_path(),
output = gsub(".mid$", ".mp3", midifile),
live = interactive(),
verbose = interactive(),
overwrite = TRUE,
...
)
midifile |
Path to the midi file to synthesize on; character string. |
soundfont |
path to sf2 sound font (character string); if not specified,
the default soundfont of the fluidsynth package ( |
output |
Path to the audiofile to be synthesized. (character string). |
live |
logical; if |
verbose |
logical whether to print command line output; defaults to FALSE |
overwrite |
logical; defaults to TRUE; if file exists and overwrite = FALSE, the existing files will not be overwritten and the function errors out. |
... |
Arguments passed to the fluidsynth functions
( |
If live = TRUE
, nothing is returned. If live = FALSE
, a html
audio tag is returned that will render as a small audio player when knitting
an Rmd document. The audio player can then play the generated output
audio file.
midi_file_string <- system.file("extdata", "test_midi_file.mid", package = "pyramidi")
midi_file_string |> player()
# The player is a small helper function to do basically this:
## Not run:
midifile <- system.file("extdata", "test_midi_file.mid", package = "pyramidi")
mp3file <- "test.mp3"
fluidsynth::midi_convert(midifile, output = mp3file)
# `overwrite` = TRUE overwrites the mp3 file if previously existing.
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.