This function creates a MIDI matrix for a given musical score.
Arguments
- df
A data.frame containing the input MIDI notation. df has at least columns named 'bars', 'note', and 'bar_steps'. 'bars' indicates which bar the note occurs in, note' indicates the pitch of the note, bar_steps' shows the time position within the bar that the note occurs.
- num_notes
An integer determining the size of MIDI note bins. Default is 128.
- intervals_per_bar
An integer specifying the number of intervals to split each bar into for matrix preparation. Default is 48, which corresponds to 48th notes (or every quarter beat in a 4/4 signature).
- separate
A logical value indicating if the function should return a single concatenated matrix (FALSE) or a list of separate pitch, time, and pitch by time matrices (TRUE). Default is FALSE.
Value
If separate = FALSE, a matrix of MIDI note data with rows representing bars, and columns representing 1) counts of notes in pitch bins, 2) counts of notes in time bins, and 3) a matrix 'flattened' to a vector of pitch by time data. If separate = TRUE, a list containing separate matrices for pitch, time, and pitch by time.
Examples
if (FALSE) {
copy_track <- copy_and_extend_midi_df(midi_df, track_num = 0)
metric_tibble <- make_metric_tibble(copy_track, ticks_per_beat = 96, bars=48,smallest_tick=8)
copy_track <- add_bars_to_copy_df(copy_track,metric_tibble)
music_matrix <- create_midi_matrix(copy_track,128,48)
}