适用于 Python 的简单跨平台 MIDI 库
我想构建一个创建 MIDI 声音的小应用程序。 我从来没有在编程中处理过声音,所以我想从一些基本的并且有良好文档的东西开始。 我想坚持使用 Python,因为我对它最熟悉,并且一开始不想让自己不知所措。
我的时间在 Windows 和 Ubuntu 上各占一半,所以在这两个平台上“都能正常工作”的东西会非常有帮助。
有什么建议么?
I want to do build a small app that creates MIDI sounds. I've never dealt with sound in programming so I'd like to start with something that's basic and has good documentation. I want to stick with Python since I'm the most comfortable with it and don't want to overwhelm myself, initially.
My time is split about 50/50 between Windows and Ubuntu so something that "just works" on both platforms would be really helpful.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
MIDIUtil 库(托管在 Google 代码此处)可实现您想要的功能:从纯Python库。 它的一个好处(并且完全公开:我是作者)是您不必跟踪较低级别的 MID 事件,例如音符打开和音符关闭:它会为您处理它们。
作为写注释的示例,您可以执行以下操作:
希望这有帮助
The MIDIUtil Library (hosted here at Google Code) does what you want: write MIDI Files from a pure Python library. Once nice thing about it (and full disclosure: I'm the author) is that you don't have to keep track of lower-level MID events such as note-on and note-off: it handles them for you.
As an example to write a note, you would do something like:
Hope this helps
我正在寻找一个纯Python库来生成MIDI文件,mxm的Python MIDI库正是如此。
从 这个 dzone 片段 中,有一个上述库的单文件版本,smidi.py (gist'd here 供后代使用)
用法非常简单:
大概适用于 Windows(因为原始示例使用
C:\out.mid
作为输出文件名) ,我已经在 OS X 上测试过了I was looking for a pure-Python library to generate a MIDI file, mxm's Python MIDI library is exactly that.
From this dzone snippet, there is a single-file version of the above library, smidi.py (gist'd here for posterity)
Usage is quite simple:
Presumably works on Windows (as the original example uses
C:\out.mid
as the output filename), and I've tested it on OS XpyPortMidi 是 PortMidi 的 Python 包装器,它被描述为“一个交叉- 用于实时 MIDI 控制的平台 C 库”。 我自己还没有使用过它,但它看起来很有前途。 明确提到能够实时发送 MIDI 数据。
pyPortMidi is a Python wrapper of PortMidi, which is described as a "a cross-platform C library for realtime MIDI control". I haven't used it myself, but it looks very promising. Explicit mention of being able to send MIDI data in realtime.
如果您只需要生成 Midi 或处理 midi 文件,请尝试 mingus,
这是一个很棒的软件包,它还允许更高的抽象,例如和弦、和弦进行、音阶等等。
If you only need to generate Midi or process midi files, try mingus,
It's a great package and it also allows much higher abstractions such as chords, chord progressions, scales and so on.
我尝试了 wiki http://wiki.python.org/moin/PythonInMusic 上列出的八个软件包。
我发现 music21 (http://web.mit.edu/music21/) 是
,但就您对简单性的要求而言,我认为这不是最简单的。 但我无法让任何其他程序以可靠的方式读取 MIDI 文件(我有各种奇怪而美妙的 MIDI 文件格式)
I tried eight packages listed on the wiki http://wiki.python.org/moin/PythonInMusic.
I found that the one that music21 (http://web.mit.edu/music21/) was
but as to your request for simplicity, I think it's not the simplest one. But I couldn't get any of the other programs to read midi files in a robust way (I have a variety of weird and wonderful midi file formats hanging around)
pyGame 1.9 中添加了 Midi 支持(输入和输出),尽管它主要处于开发阶段并且尚未有很好的文档记录,但它确实有效。
pyGame 的后继者 pgreloaded(或 pygame2)也正在开发 Midi 支持。
另请注意,尽管 pyGame 的标题中有“游戏”,但它的用途远远超出了游戏设计的范围。
Midi support (in and out) has been added to pyGame 1.9, though it's mainly in the development stage and isn't very well documented yet, but it works.
Midi support is also being developed in the pyGame successor, pgreloaded (or pygame2).
Also note that even though pyGame has 'game' in the title, its uses stretch far beyond just game design.
查看 cSounds。
Look at cSounds.