从MIDI文件获取音符数据 [英] Get note data from MIDI file

查看:687
本文介绍了从MIDI文件获取音符数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从MIDI文件中获取音符数据?也就是说,我想将MIDI文件分解为组成部分,以便它们以唯一单词(或任何其他数据类型)的形式出现. 最后,我要输入的是MIDI文件,然后在音符中找到模式.进入每个音符,找到其出现的频率(频率),并记下其后将演奏其他音符的​​可能性.

Is there a way to get the note data from a MIDI file? That is, I want to break down the MIDI file into its constituent parts so they are in the form of a unique word (or any other data type). What I want to do in the end is take in a MIDI file and find patterns in the notes. Get in each note, find it's frequency (of being played) and note how likely other notes are to be played after it.

用C/C ++做到这一点很好,但是任何语言都可以.

It would be nice to do this in C/C++, but any language would be fine.

推荐答案

Nik Reisman-抱歉,但我不同意...在C#中解析midi,C ++大约包含400行代码.努力,这并不困难.

Nik Reisman - sorry, but I don't agree with you...parsing midi in C#, C++ is something about 400 rows of code..It's nothing hard and it is nothing difficult.

我建议您从以下链接开始: https://web.archive.org/web/20141227205754/http://www.sonicspot.com:80/guide/midifiles.html
您需要了解有关Midi以及如何阅读它的所有信息.

I will advise you start with this link: https://web.archive.org/web/20141227205754/http://www.sonicspot.com:80/guide/midifiles.html
There is everything you need to know about midi and how to read it..

在简短描述中,解析器将如何工作:
1)以字节模式打开midi
2)读取标题块,其中包含有关大小,轨道数和重要文件格式的信息!
-共有3种格式:0,1,2(类型2确实是有价值的",只有很少的Midi文件具有这种类型,因此,如果有类型2,则不需要读取Midi).
-如果未写入:"MThd" (0x4D546864),则以错误结尾(这是错误的midi文件)
3)读取曲目块
-如果未写入:"MTrk" (0x4D54726B)以错误结尾(这是错误的midi文件)
4)阅读MIDI事件. -事件非常多,您可以使用if-else命令将其全部读取,也可以仅读取想要了解的事件,例如NOTE ON,NOTE OFF -有时在某些midi文件中没有注意关闭" ..此事件通过注意开启"和速度0更改.

In the short description how the parser will work:
1)Open midi in byte mode
2)Read the header chunk where there is info about size, number of tracks and IMPORTANT file format!!
- There are 3 types of formats: 0,1,2 (type 2 is really "valuable", there are only few midi files with this type, so you don't need to read the midi if there is type 2)
- if there is not written: "MThd" (0x4D546864), end with error (it's a bad midi file)
3)Read track chunk
- if there is not written: "MTrk" (0x4D54726B) end with error (it's a bad midi file)
4)Read the midi events.. - There are very many events, you can read them all with if-else commands, or you can read only the events what you want to know, for example NOTE ON, NOTE OFF - Sometimes in some midi files are not NOTE OFF..this event is changed with NOTE ON and velocity 0

在网站上,所有内容都得到了很好的解释.如果以字节模式打开midi文件,则只有几种方法,所有内容仅与if-else命令有关,在那里您将捕获到当前存储的内容.
重要的是要了解可变长度,但在网站上也有解释.不难您可以在许多网站上搜索Google可变长度,并附带一些图片和示例.因此,我认为在这里很难解释.

On the websites everything is explained really nicely. If you open the midi file in byte mode you will have only a few methods and everything is then only about if-else commands and there you will catch what is stored right now.
It is important to understand VARIABLE LENGTH, but on the websites it is also explained. It's not hard. You can google many sites where VARIABLE LENGTH is explained too, with some images and examples. So I don't think that it is hard to explain it in here.

如果您需要更多建议,请给我写信,我会尝试的.但是解析midi并不像看起来那样困难.如果您有任何问题,请写信给我.

If you want a bit more advice, write me, I will try it. But parsing midi is not as hard as how it looks. If you have some problems, write me..

这篇关于从MIDI文件获取音符数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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