knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
pyramidi::install_miditapyr(envname = "r-reticulate")
The following diagram depicts the structure of the pyramidi package and its python counterpart miditapyr.
Hover over nodes to see additional information. Many of the nodes are also clickable for further information.
library(pyramidi) library(stringr) library(purrr) library(DiagrammeR) mt_funs <- c("frame_midi", "unnest_midi", "nest_midi", "write_midi") mt_fun_descrs <- map_chr(mt_funs, ~miditapyr[[.x]]$`__doc__`) %>% str_split("\\n\\n") %>% map_chr(1) %>% str_replace_all("\\n", " ") %>% str_squish() %>% str_remove_all(":.*?:") %>% str_remove_all("[`~]") pm_funs <- c( "pivot_long_notes", "pivot_wide_notes", "tab_measures", "merge_midi_frames", "split_midi_frame" ) # inspired by: # https://stackoverflow.com/a/8928894 & # https://stackoverflow.com/a/23897916 get_help <- function(...){ thefile <- help(...) capture.output( tools:::Rd2txt(utils:::.getHelpFile(thefile)) ) } pm_fun_descrs_raw <- map(pm_funs, get_help) %>% map(~.x[-c(1:4)]) title_until_line_ints <- pm_fun_descrs_raw %>% map_dbl(~str_which(.x, "^$") %>% min() %>% {. - 1}) pm_fun_descrs <- map2_chr( pm_fun_descrs_raw, title_until_line_ints, ~ .x[1:.y] %>% paste(collapse = " ") %>% str_squish() %>% str_remove_all("[`'\"’‘]") ) gv <- grViz("package_workflow.gv")
# chunk options from here: https://stackoverflow.com/a/43213737
gv
miditapyr
can be used to load the midi file midi_in
into a mido.MidiFile
.
The chain down to midi_out
shows, how miditapyr's functions can be used
to transform the data into different formats and finally save it to a new midi file.
Have a look here
to see in detail how this can be done.mf
shows the structure of a
MidiFrames
object and how its fields are related to the low-level functions. Have a look
here
to see how MidiFrames
can be used in python.pyramidi
subgraph illustrates how the functions in this package work.
Starting from the dataframe midi_frame_unnested
, the data is transformed to
different formats, finally resulting in the same format.MidiFramer
object (for clarity not included in the graph). MidiFramer
method update_nodes_wide()
can be used to modify the
field df_notes_wide
. The red arrows and borders show the other fields of the
MidiFramer
object that are automatically updated when using this method.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.