Kindly bear with my ignorance on music and the question comes from my project on blender using pythons music21 module. So my project is that if i pass a midi file, the code should create keyframes and animate the keys of a grand piano that i have modeled in blender. I extracted notes and chords from the midi file but i'm not sure what parameters define the actual duration in seconds of the keys being held pressed. Any suggestions or references to hopefully specific part of a book or a site regarding my question is much appreciated. Thank you.

  • 2
    This is not about MIDI but the music21 library. You're not dealing with MIDI events at all after you've parsed the music with music21.converter.parse, you're dealing with music21 objects and their properties. Read the documentation and do the tutorials. Note duration in seconds depends on the song tempo and the note's musical duration. web.mit.edu/music21/doc/moduleReference/… Jun 29, 2020 at 18:59

1 Answer 1


The main thing you should look for is note-on and note-off messages, and timestamps, i.e. when a particular note-on or note-off is to be performed.

Timestamps are of different kinds (absolute, relative, milliseconds, frames, etc.)

You should probably start by reading the general MIDI specifications and about the main MIDI file formats, but I would also suggest that you look for some open source code project in your favorite language where MIDI messages or files are handled, and see how that works, and try modifying it, etc. rather than starting everything from scratch yourself.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.