How to convert midi timeline into the actual timeline that should be played

痞子三分冷 提交于 2019-12-01 17:05:02

If I understand your question correctly, you basically want to convert the ticks for each MIDI note into a millisecond value so you can display the notes visually along a timeline.

So first, you need to use the division and the tempo to determine the value of an individual tick. That conversion basically looks like:

 [  1 min    60 sec   1 beat     Z clocks ]
 | ------- * ------ * -------- * -------- | = seconds
 [ X beats   1 min    Y clocks       1    ]

So, in the above conversion, X is the tempo, Y is the division, and Z is the number of clocks from the incoming event. You can see how all of the units cancel out, giving you a value in seconds. The condensed version of that conversion is therefore:

(60 * clocks) / (tempo * division) = seconds

Keep in mind that the value given here in seconds is the number of seconds since the previous MIDI event, not from the sequence start. You will need to keep a running total of this value to construct a coherent sequence.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!