在 Python 中合成音符(带有钢琴声音)
我想要一个乐器库(例如,钢琴对象)的 python 实现,我可以用它来将音符列表和持续时间转换为声音。例如,类似这样的内容:
import Piano
pn = Piano()
pn.play([note, note, ..., note], duration)
Python 2.7 是否存在类似的内容?如果没有的话我想实现它。我目前有一些使用 audiere 的东西,但它只是正弦波,所以听起来很糟糕。有没有办法连接到 midi 钢琴或类似的东西 - 我使用的是 Windows 7?是否有任何我可能意想不到的实施步骤?
I would like to have a python implementation of a musical instrument library (for instance, a piano object) that I can use to convert a list of notes and a duration into sound. For instance, something like:
import Piano
pn = Piano()
pn.play([note, note, ..., note], duration)
Does something like this exist for python 2.7? I would like to implement it if it doesn't. I currently have something that uses audiere, but its just sine waves so it sounds horrible. Is there any way to hook into a midi piano or something like that- I am using windows 7? Are there any implementing steps that I might not expect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的一个学生刚刚开始使用 mingus 来做到这一点,所以这里有一个关于如何在 linux (ubuntu) 上进行操作的快速指南:
如果您还没有 Fluidsynth 和 mingus,请安装它们:
$
sudo apt-get install Fluidsynth$
sudo easy_install mingus现在你应该能够打开 python 并输入:
这将从 mingus 导入必要的内容并初始化 Fluidsynth通过 alsa 播放(不是默认的 jack)。然后:
...您应该听到钢琴上弹奏的音符(参数为:音符编号、通道编号和力度)。
如需了解更多信息,请访问此处:
https://code.google.com/p/mingus/wiki/tutorialFluidsynth
A student of mine has just started using mingus to do just this so here's quick guide on how to get going on linux (ubuntu):
Install fluidsynth and mingus if you don't have them already:
$
sudo apt-get install fluidsynth$
sudo easy_install mingusNow you should be able to open python and type:
This imports the necessary stuff from mingus and initialises fluidsynth to play through alsa (not jack which is the default). Then:
...and you should hear a note played on the piano (arguments are: note number, channel number and velocity).
For more information go here:
https://code.google.com/p/mingus/wiki/tutorialFluidsynth
@Marcelos 答案的子集:http://code.google.com/p/mingus/
A subset of @Marcelos answer: http://code.google.com/p/mingus/