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