MIDI ticks, duration and real-time with MPTK

Creating a game or an application in Unity that involves MIDI, such as a rhythm game or tutorial, often requires knowing the real-time value of each note. This post can be a valuable resource.

Be sure to read the chapter “How Maestro MPTK could help you” as it offers significant insights. The initial chapter, while somewhat intricate, is beneficial for those seeking to comprehend MIDI.

The MIDI Standard

As you may be aware, the timing of MIDI events is determined by the number of ticks since the previous event on the same track. Consequently, it is a relative value, not tied to the tempo, and indeed, it is independent of real time.


The MPTK_DeltaTicksPerQuarterNote which is a fixed value for each MIDI, indicate the duration time in “ticks” constitute a beat.

Typically, a beat corresponds to a quarter note, but this can vary depending on the time signature. For instance, in a 4/4 time signature, the beat is a quarter note, while in a 4/2 time signature, it is a half note. Additionally, it’s important to remember that the time signature may change during the course of a MIDI sequence. More details here.

For example, if the Division of Ticks Per Quarter Note (DTPQN) is 96, then the tick value for an eighth note in a 4/4 time signature would be 48 (since an eighth note is half a quarter note). With a tempo of 120 Beats Per Minute (BPM), the duration of this eighth note would be 0.25 seconds (as 120 BPM equals 120 quarters per minute, or 2 quarters per second, which translates to 4 eighth notes per second)..


Determining the actual duration of an event, such as a MIDI Note-On, can be intricate due to its reliance on the interval of ticks between the Note-On event and subsequent Note-Off event, rather than a specified duration within the event itself.

You’re always there? Excellent! Now for the good news. Fortunately, Maestro MPTK automatically performs all these calculations when the MIDI is loaded.

How Maestro MPTK could help you?


In Maestro MPTK, each MIDI event is represented by an instance of the class MPTKEvent class, which includes several useful attributes:

  • Tick: The absolute time in ticks of an event, from the start of a MIDI file playback, is independent of the tempo.
  • RealTime: time in milliseconds of this MIDI Event from the beginning of the MIDI, accounting for the changes in tempo.
  • Duration: The duration of a note in milliseconds related to changes in tempo and time signature.
  • Beat and Measure of each event are determined by the time signature change event.

Normally, you should not need to convert tick values to real-world time values yourself.

Other interesting attributes and classes include:

You can access to these attributs when the MIDI is loaded with:

  • midiFilePlayer.MPTK_MidiLoaded
  • See MaestroOnEventStartPlayMidi() method in the demo source file Assets\MidiPlayer\Demo\FreeDemos\Script\TestMidiFilePlayerScripting.cs

Note-On vs Note-Off

In progress …

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.