Create melody dataframe

Create melody dataframe#

To extract the melody and time in seconds (needed for animation) from the pyramidi output took only a small bit of wrangling. I used a little modulo operation so that I could pivote the notes into a wide format I could experiment with in gganimate.

pyramidi_raw %>% 
dplyr::mutate(
    status = dplyr::if_else(time == 0, 'on', 'off'),
    ii_note = (i_note + 1) %/% 2,
    note_name = stringr::str_remove(note_name, '\\d+')
) %>% dplyr::select(ii_note, note, note_name, t, status) %>%
tidyr::pivot_wider(names_from = status, values_from = t) 

readRDS(url('https://github.com/softloud/digmus/raw/main/outputs/step-output/melody_df.rds'))
A tibble: 12 × 5
ii_notenotenote_nameonoff
<dbl><dbl><chr><dbl><dbl>
162D 0.0 1.2
169A 1.2 2.4
165F 2.4 3.6
262D 3.6 4.8
161C#4.8 6.0
362D 6.0 6.6
164E 6.6 7.2
265F 7.2 8.7
167G 8.7 9.0
365F 9.0 9.3
264E 9.3 9.6
462D 9.610.2