简体   繁体   English

了解如何将Midi文件映射到javascript中的对象

[英]Understanding how midi file is mapped to object in javascript

I'm using this library I found to read a midi file 我正在使用发现有读取Midi文件的库

As there is very little documentation, I have no idea how to read the output object? 由于文档很少,所以我不知道如何读取输出对象?

question: What does: Channel, data, deltaTime and type keys mean? 问题:通道,数据,deltaTime和类型键是什么意思?

In the end I would love to map this js object to some kind of visualization. 最后,我希望将此js对象映射到某种可视化形式。 在此处输入图片说明

Channel : The MIDI format uses the concept of channels to allow different MIDI devices to only listen to specific MIDI events by listening to such a channel. 通道 :MIDI格式使用通道的概念,以允许不同的MIDI设备仅通过监听这样的通道来监听特定的MIDI事件。 This makes it possible to use a single MIDI file for multiple instruments that should play different notes, etc. So when you have a note on event you should check the channel of the event and only play the instruments that are interested in events that happen in this channel. 这样就可以将一个MIDI文件用于应演奏不同音符等的多种乐器。因此,当您在事件上有音符时,应检查事件的通道,仅播放对发生在其中的事件感兴趣的乐器这个频道。

Data : Data is a bit arbitrary, but in your example we have an event of type 255 (0xFF) which is a meta event. 数据 :数据有点随意,但是在您的示例中,我们有一个类型为255(0xFF)的事件,它是一个元事件。 It has a meta type of 3 (0x03) which means it's a Sequence/Track-name. 它的元类型为3(0x03),表示它是序列/音轨名称。 This was probably assigned by the program that created the MIDI file you use. 这可能是由创建您使用的MIDI文件的程序分配的。 There's a pretty nifty and concise list of events here: http://www.ccarh.org/courses/253/handout/smf/ 这里有一个非常漂亮而简洁的事件列表: http : //www.ccarh.org/courses/253/handout/smf/

deltaTime : Since events in the MIDI file is tempo agnostic it uses the concept of ticks. deltaTime :由于MIDI文件中的事件是速度不可知的,因此它使用了滴答声的概念。 It's basically a resolution expressed as ticks per quarter note. 这基本上是一种分辨率,表示为每四分音符的刻度。 I think 480 ticks per quarter note is pretty standard, though that is purely based on my own experience, so YMMV. 认为每四分音符480滴答声是很标准的,尽管这完全基于我自己的经验,所以是基于YMMV。 Events can then either be expressed in absolute time (ie. this note on events happens 4800 ticks from the start of the track) or delta time. 然后,事件可以以绝对时间(即,该事件的注释在音轨开始4800滴答处发生)或增量时间表示。 Delta time is the number of ticks since the last MIDI event happened. 增量时间是自上次MIDI事件发生以来的滴答声数量。

Type : Each MIDI event in a MIDI file has a type to identify what kind of an event it is. 类型 :MIDI文件中的每个MIDI事件都具有一种类型,以识别事件的类型。 This matters since different types of events has different formats (and thus changes the way we decode it, since MIDI is a binary format), where some have a fixed length and others include information on how long the event is (the number of bytes that make up the event). 这很重要,因为不同类型的事件具有不同的格式(由于MIDI是二进制格式,因此改变了我们解码的方式),其中一些具有固定的长度,而另一些包含有关事件持续时间(字节数)的信息。弥补事件)。

It's been a couple of years since I last worked with the MIDI format, but I think the above is accurate. 自从我上一次使用MIDI格式已经过去了两年,但是我认为以上是正确的。

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

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