简体   繁体   English

如何将midi时间轴转换为应该播放的实际时间轴

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

I have researched the subject for some time now and still haven't figure it out. 我已经研究了这个主题一段时间了,但仍然没有弄清楚。 I use midas3 library (Midi-actionscript3) to import midi to flash. 我使用midas3库(Midi-actionscript3)将midi导入flash。 I get each note-item on a timeline. 我在时间轴上得到每个音符项目。 I get the divisions value (192) and all of the "GET-TEMPO" elements are equal to 81. 我得到除法值(192),所有“GET-TEMPO”元素都等于81。

I tried a lot of combinations to get the actual time of the midi but still no good (timeline*192/60 for example). 我尝试了很多组合来获得midi的实际时间但仍然没有好处(例如时间线* 192/60)。

The reason I know it is not synchronized to the actual time is that when I visualize the notes as simple rectangles in flash - I check if they appear exactly to what the mp3 file plays (I have converted the midi file to this mp3 using simple conversion program) 我知道它与实际时间不同步的原因是当我将笔记可视化为flash中的简单矩形时 - 我检查它们是否与mp3文件播放完全一致(我已经使用简单转换将midi文件转换为此mp3程序)

I have read a lot about how all is calculated but still haven't figure out the number I need to use to get it right (timeline * MysteriusConstant = ReaTIME, what is the value of MysteriusConstant? is it really constant? and if not how do I calculate how it is changed?) 我已经阅读了很多关于如何计算所有内容的信息,但仍然没有弄清楚我需要使用的数字才能使它正确(时间轴* MysteriusConstant = ReaTIME,MysteriusConstant的值是什么?它是否真的不变?如果不是如何?我可以计算出它的变化吗?)

thanks Alon 谢谢Alon

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. 如果我正确理解你的问题,你基本上想要将每个MIDI音符的刻度转换为毫秒值,这样你就可以在时间轴上直观地显示音符。

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. 因此,在上面的转换中, X是速度, Y是除法, Z是来自传入事件的时钟数。 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. 请记住,此处以secondsseconds的值是自上一个 MIDI事件以来的秒数,而不是序列开始的秒数。 You will need to keep a running total of this value to construct a coherent sequence. 您需要保持此值的运行总计以构建连贯的序列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM