开源 MIDI 库

发布于 2024-08-23 08:49:57 字数 388 浏览 9 评论 0原文

我想了解可用于对 MIDI 文件执行一些简单任务的开源库:

  1. 一次读取一个音符或和弦的文件;
  2. 提取给定的乐器以将其单独重新编码到新文件中;
  3. 允许生成“可定制”乐谱——我的意思是我应该能够使用库改变从 midi 生成乐谱的方式...我认为这需要与 Lilypond 或 Musixtex 进行交互。

我确实没有首选语言,只要使应用程序跨平台不是太痛苦即可。欢迎其他建议——现在学习比我已经写了很多代码更好。到目前为止,我一直在尝试挖掘 MuseScore 的(C++)源代码,但似乎 GUI 代码渗透到大多数文件中,虽然发现相关文件很容易,但我很难提取我需要的内容(我是目前仅针对命令行应用程序,稍后我将了解接口)。

有什么想法吗?

谢谢!

I would like to know about open source libraries that could be used to perform some simple tasks on MIDI files:

  1. reading a file one note - or chord - at a time;
  2. extracting a given instrument to re-encode it separately in a new file;
  3. allow to produce a "customizable" score -- by that I mean that I should be able to alter the way the sheet music is produced from the midi using the libraries ... I assume this will require an interaction with Lilypond or Musixtex.

I don't really have a preferred language, as long as it is not too painful to make the app cross-platform. Other advice is welcome -- better to learn it now rather than when I've already written a lot of code. So far, I've been trying to dig in MuseScore's (C++) source code, but it seems that GUI code permeates most files and although spotting relevant files was easy, it is difficult for me to extract just what I need (I'm only aiming for a command line application right now, I'll see about interfaces later).

Any ideas?

Thanks!

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

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

发布评论

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

评论(2

韵柒 2024-08-30 08:49:57

好吧,我才刚刚开始,但是 (Python 中)似乎很有希望。

Well, I'm just getting started, but this (in Python) seems promising.

最笨的告白 2024-08-30 08:49:57

如果您仍在从事该项目并且语言不是问题,您可以尝试 Python 的跨平台 music21< /a> 它可以将 MIDI 文件解析为音符、和弦、乐器等对象,让您可以操纵乐谱,然后 R/T 回 MIDI 或输出到 Lilypond 等(完全公开,我是作者工具包的一部分;但我不知道有多少其他语言可以将 MIDI 引入而将 Lilypond 排除,同时让您有机会将 MIDI 元素视为对象进行操作。)。

用于将 MIDI 文件中的所有乐器声音搞乱,然后播放它并从中制作 lilypond.pdf 的示例代码:

 import music21
 mf = music21.converter.parse('pathToMidiFile.mid')
 for x in mf.recurse():
     if 'Instrument' in x.classes:
         x.midiProgram = (x.midiProgram * 2) % 128
 mf.show('midi')
 mf.show('lily.pdf')

希望有帮助。

If you're still working on the project and language isn't a problem, you might try Python's cross-platform music21 which can parse midi files into Note, Chord, Instrument, etc., objects, lets you manipulate the scores, and then R/T back to MIDI or output to Lilypond, etc. (full disclosure, I'm the author of the toolkit; but I don't know of many others in any language that will take MIDI in and put Lilypond out while giving you a chance to treat the MIDI elements as objects to manipulate in the meantime.).

Sample code to screw up all the instrument sounds in a MIDI file and then play it and make a lilypond.pdf from it:

 import music21
 mf = music21.converter.parse('pathToMidiFile.mid')
 for x in mf.recurse():
     if 'Instrument' in x.classes:
         x.midiProgram = (x.midiProgram * 2) % 128
 mf.show('midi')
 mf.show('lily.pdf')

Hope that helps.

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