Mironline
Mironline

Reputation: 2799

MIDI, how to get measures and notes

Many MIDI libraries like mido and pretty_midi provide list of all messages in MIDI files. I am looking for a code to get the list of measures and all notes in each measure. Is there a specific library for calculating beats and measures (bars)?

Upvotes: 1

Views: 1396

Answers (1)

CL.
CL.

Reputation: 180010

There is no library that does this for you. You have to determine the length, in ticks, of each measure from the time signature meta event (or events, if the signature changes), and then compute from the timestamps of the note-on and note-off messages to which measure they belong. (The two messages might end up in different measures.)

Upvotes: 1

Related Questions