从 MIDI 文件中获取音符数据

发布于 2024-09-18 06:37:10 字数 186 浏览 5 评论 0原文

有没有办法从 MIDI 文件中获取音符数据?也就是说,我想将 MIDI 文件分解为其组成部分,以便它们采用唯一单词(或任何其他数据类型)的形式。 我最终想要做的是接收 MIDI 文件并在音符中找到模式。进入每个音符,找到它的(被演奏的)频率,并注意在它之后演奏其他音符的​​可能性有多大。

用 C/C++ 来做这件事会很好,但任何语言都可以。

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

自找没趣 2024-09-25 06:37:10

Nik Reisman - 抱歉,但我不同意你的观点...在 C#、C++ 中解析 midi 大约需要 400 行代码...这没什么难的,也没什么难的。

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

在简短的描述中,解析器将如何工作:
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 文件中,NOTE OFF 不存在。此事件会通过 NOTE ON 和速度 0 进行更改。

在网站上,一切都解释得非常好。如果您以字节模式打开 midi 文件,您将只有几个方法,然后所有内容都仅与 if-else 命令有关,您将捕获现在存储的内容。
了解可变长度很重要,但在网站上也对此进行了解释。这并不难。您可以在谷歌上搜索许多网站,其中也解释了可变长度,并附有一些图像和示例。所以我认为在这里解释它并不困难。

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

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.

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..

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

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.

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..

岁月无声 2024-09-25 06:37:10

手动解析 MIDI 文件并不有趣,请相信我的话。 ;) 该格式虽然有详细记录,但很难处理,因为您始终处于原始字节级别。由于您有兴趣从 MIDI 文件本身提取一些有意义的信息,我建议使用诸如 Juce 之类的框架,用C++编写,支持读取MIDI文件。

Juce 相当大,但 API 很好并且有详细的文档。例如,用于解析 MIDI 文件的类非常简单且易于使用使用。

Parsing MIDI files by hand is no fun, take my word on this. ;) The format, although well documented, is difficult to deal with since you are always on the raw byte level. Since you are interested in extracting some meaningful information from MIDI files themselves, I'd recommend using a framework such as Juce, which is written in C++ and has support for reading MIDI files.

Juce is pretty large, but the API is good and well-documented. The class for parsing MIDI files, for instance, is pretty straightforward and easy to use.

太阳公公是暖光 2024-09-25 06:37:10

有许多现成的解决方案,从 MIDI 文件获取输入,生成音乐可视化,
所以在理论和实践中,MIDI解析器工作得很好

我正在HTML5中研究这样的音乐可视化器,生成垂直顶部>实时记录音符时间线以支持残疾钢琴演奏者。

DLP 投影仪很棒,但看来,我需要安装大型液晶电视屏幕,就在钢琴键盘上方,以实现可视化以匹配弹奏的音符

@Brendan Kavanagh 是领导者
另一位关键开发人员名叫 Stephen Malinowski,

只需按照我的问题即可获取正确的网络链接

如何构建 MIDI 文件可视化工具以从 MIDI 文件获取输入并通过键盘显示 MIDI 时间线以匹配真实演奏者演奏的音符

There is a number of ready made solutions, taking input from MIDI file, generating musical visualization,
so in theory and practice, MIDI parser works fine

I am working on such musical visualizer in HTML5, generating vertical top > down notes timeline live to support handicapped piano players.

DLP projector is great but it seems, I need to install large LCD TV screen, just over the piano keyboard to get visualization to match the notes played

@Brendan Kavanagh is the leader
another key developer is called Stephen Malinowski

just follow my question to get the right web links

How to build MIDI file visualizer to get input from MIDI file and display MIDI timeline over the keyboard to match notes played by a real player

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文