Skip to contents

The function reads a binary matrix where pitch classes are on the rows and temporal locations on columns (1s represent note onsets, 0s represent absences of notes). It then converts this binary representation into MIDI timings, i.e. the time (in ticks) of note onsets and note offsets.

Usage

matrix_to_midi_time(midi_matrix, smallest_time_unit = 8, note_off_length = 32)

Arguments

midi_matrix

A binary matrix, where pitch classes are on rows and temporal location are on columns. Each cell value should either be 1 (note onset) or 0 (notes absence).

smallest_time_unit

Integer, specifying the smallest time unit (in MIDI ticks) that is used in the binary matrix representation. Default is 8 ticks.

note_off_length

Numeric, specifying a fixed note duration in MIDI ticks that will be used for all the notes in the sequence. Default is 32 ticks.

Value

A dataframe with four columns: note_num, note_id, type, time. note_num is the MIDI pitch of each note. note_id is a unique identifier for each note. type whether the event is a note onset ("note_on") or a note offset ("note_off"). time is the time (in MIDI ticks) since the last event.

Examples

if (FALSE) {
}