0

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)?

Mironline
  • 2,755
  • 7
  • 35
  • 61
  • What does "in a measure" mean? And what would you need this information for? – CL. Jun 24 '20 at 20:39
  • @CL.Actually, I need all notes in each measure. I want to calculate the note ranges in each measure for statistics purposes. – Mironline Jun 24 '20 at 20:59
  • 1
    If you're happy with .NET too, you can use my library [DryWetMIDI](https://github.com/melanchall/drywetmidi) that has all these high-level calculations. – Maxim Jun 25 '20 at 08:48

1 Answers1

1

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.)

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Maybe it would be better to write "There is no library for Python"? :) Since with [DryWetMIDI](https://github.com/melanchall/drywetmidi) (.NET library) it's easy to solve the task. – Maxim Jun 25 '20 at 08:52