Convert midi to R object using pyramidi#
Heading links to the script
The pyramidi package provides a framework for translating midi files to R objects.
After some experimentation, I used the code in the translate midi time information section as I wanted access to pyramidi::tab_measures. From there I could extract a dataframe of the notes of the melody.
readRDS(url('https://github.com/softloud/digmus/raw/main/outputs/step-output/pyramidi_notes.rds')) |>
    head()
| i_track | meta | type | time | program | channel | note | velocity | ticks | t | m | b | i_note | note_name | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| <dbl> | <lgl> | <chr> | <dbl> | <dbl> | <dbl> | <dbl> | <dbl> | <dbl> | <dbl> | <dbl> | <dbl> | <dbl> | <fct> | |
| 1 | 1 | FALSE | note_on | 0 | NaN | 0 | 62 | 90 | 0 | 0.0 | 0 | 0 | 1 | D4 | 
| 2 | 1 | FALSE | note_on | 768 | NaN | 0 | 62 | 0 | 768 | 1.2 | 2 | 8 | 2 | D4 | 
| 3 | 1 | FALSE | note_on | 0 | NaN | 0 | 69 | 90 | 768 | 1.2 | 2 | 8 | 1 | A4 | 
| 4 | 1 | FALSE | note_on | 768 | NaN | 0 | 69 | 0 | 1536 | 2.4 | 4 | 16 | 2 | A4 | 
| 5 | 1 | FALSE | note_on | 0 | NaN | 0 | 65 | 90 | 1536 | 2.4 | 4 | 16 | 1 | F4 | 
| 6 | 1 | FALSE | note_on | 768 | NaN | 0 | 65 | 0 | 2304 | 3.6 | 6 | 24 | 2 | F4 |