1

I understand the note/pitch and the velocity components of a message. However, I am having difficulty understanding the time attribute. According to the documentation of mido, a library that I am using to read MIDI files, the time attribute denotes the delta time that has elapsed since the last message.

Firstly, how is this delta time measured? As in, in what units is time discretised?

For example, take the following piece by Liszt. I find that sometimes the time attribute is 0. Does this imply the previous note and the current are being played together?

The ultimate aim is to convert a MIDI file into a Piano-roll in Python. When read in Python, this is a small part of the message:

Track 0: Rhapsodie Nr. 10
<meta message track_name name='Rhapsodie Nr. 10' time=0>
<meta message copyright text='Copyright © 2005 von Bernd Krüger. ' time=0>
<meta message text text='Franz Liszt' time=0>
<meta message text text='Fertiggestellt am  28.5.2005\n' time=0>
<meta message text text='Update am 9.4.2011\n' time=0>
<meta message text text='Update am 8.3.2014\n' time=0>
<meta message text text='Dauer:  4:39 Minuten\n' time=0>
<meta message text text='Notation im 4/4 statt im 2/4 Takt.\n' time=0>
<meta message time_signature numerator=5 denominator=4 clocks_per_click=24 notated_32nd_notes_per_beat=8 time=0>
<meta message key_signature key='E' time=0>
<meta message set_tempo tempo=525394 time=0>
<meta message marker text='Preludio' time=0>
program_change channel=0 program=0 time=0
control_change channel=0 control=7 value=100 time=0
control_change channel=0 control=10 value=64 time=0
note_on channel=0 note=47 velocity=77 time=0
control_change channel=0 control=91 value=127 time=0
<meta message text text='bdca426d104a26ac9dcb070447587523' time=0>
program_change channel=0 program=0 time=0
control_change channel=0 control=7 value=100 time=0
control_change channel=0 control=10 value=64 time=0
control_change channel=0 control=91 value=127 time=0
<meta message text text='bdca426d104a26ac9dcb070447587523' time=0>
note_on channel=0 note=35 velocity=61 time=0
program_change channel=0 program=0 time=0
control_change channel=0 control=64 value=127 time=0
note_on channel=0 note=35 velocity=0 time=90
note_on channel=0 note=47 velocity=0 time=0
1

The delta time is measured in ticks.

If a delta time is zero, then this message is to be sent at the same time as (immediately after) the preceding message. (Please note that a note-on message with a velocity of zero is actually a note-off.)

The file header specifies the number of ticks per beat, and the tempo messages specify the length of a beat, in microseconds. You can compute a delta time value in microseconds with tempo * delta_ticks / ticks_per_beat, but you have to take care to merge all tracks first because a tempo message in another track can change that value at any time. See this answer.

| improve this answer | |
  • "a note-on message with a velocity of zero is actually a note-off" only with running status enabled, in which case it doesn't carry a status byte at all. – Tetsujin May 7 at 12:07
  • @Tetsujin Running status and velocity=0 are two entirely orthogonal mechanisms. – CL. May 7 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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