如何计算一个的MIDI文件的时间长度 [英] How to calculate the time-length of a midi-file

查看:478
本文介绍了如何计算一个的MIDI文件的时间长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读MIDI文件在AS3(闪光CS5)乐于助人库的帮助那个叫做MIDAS ( HTTP://$c$c.google.com/p/midas3/ ) - 将MIDI-AS3库

I am reading midi files in as3 (flash cs5) with the help of the helpful library that is called midas ( http://code.google.com/p/midas3/) - the midi-as3 library.

我试图找出一个简单的方法来计算MIDI文件的整个持续时间(例如 - 4到6分钟......总时间)。我想我可以计算出最后一个音符每首曲目的+检查的节奏和看着办吧,但我想知道,如果:

I am trying to figure out a simple way to calculate the whole duration of the midi file (for example - total time of 4 minutes or 6 minutes...). I assume I could calculate the last note of each track + check the tempo and figure it out, but I was wondering if:

时的MIDI文件的持续时间的某个地方写入数据,我可以只拉出来,并使用?

Is the duration of the midi file is written somewhere in the data that I could just pull out and use?

有没有一种简单的方法来计算的话,而无需通过整个文件运行,比较过去的音符/节奏。

Is there an easy way to calculate it without running through the whole file and compare last-notes/tempos.

推荐答案

不,你需要的时候,你看最后一个音符读取整个文件,并确定时间。 MIDI文件基本上是流数据,所以在文件的报头没有长度字段。

Nope, you need to read the entire file and determine the time when you read the last note. MIDI files are essentially streaming data, so there is no "length" field in the file's header.

编辑:经过进一步思考,流不完全是一个伟大的方式来描述MIDI文件。 MIDI文件做有一个固定的字节长度,它是存储在IFF组块头。然而,没有任何财产,以秒为文件的长度,但假设你可以阅读所有的字节到一个序列(不要忘记带节奏的变化考虑在内!),应该不会太困难确定以秒为单位的文件的长度。

Upon further thought, "streaming" isn't exactly a great way to describe MIDI files. MIDI files do have a fixed length in bytes, which is is stored in the IFF chunk header. However, there is no property as for the length of the file in seconds, but assuming that you can read all of the bytes into a sequence (and don't forget to take tempo changes into account!), it should not be too difficult to determine the length of the file in seconds.

这篇关于如何计算一个的MIDI文件的时间长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆