使用Fluidsynth合成Python MIDI

7

我无法导入fluidsynth模块。[也许有更好的模块?]

我正在尝试从python或pygame合成midi。我可以从pygame发送midi事件。 我使用了mingus,看起来pyfluidsynth会是一个好选择/最简单的。

我认为这意味着已经安装了pyfluidsynth,但是没有单独安装fluidsynth。我不知道它是否需要一个“fluidsynth”安装程序才能工作?

test.py:

import fluidsynth
print ":("

错误:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import fluidsynth
  File "C:\Users\jake\AppData\Roaming\Python\Python27\site-packages\fluidsynth.py", line 34, in <module>
    raise ImportError, "Couldn't find the FluidSynth library."
ImportError: Couldn't find the FluidSynth library.

使用:python 2.7-win32


你试过 https://github.com/MostAwesomeDude/pyfluidsynth 吗? - endolith
3个回答

3

是的,你还需要FluidSynth库 (Windows下的dll文件)。

要使其与以下内容兼容:

  • fluid synthsynth 1.1.6
  • python26 (32位)
  • pyFluidSynth 1.1.4
  • Windows

我把所有东西都放在了同一个目录中 (fluidsynth dll、PyFluidSynth模块、Python脚本)。

并将pyFluidSynth模块中的以下行更改为 (从第30行开始):

# A short circuited or expression to find the FluidSynth library
# (mostly needed for Windows distributions of libfluidsynth supplied with QSynth)
# and Dynamically link the FluidSynth library

lib = find_library('fluidsynth') or find_library('libfluidsynth') or find_library('libfluidsynth-1')
if lib is None:
   _fl = ctypes.cdll.LoadLibrary("./libfluidsynth")
   lib = "ok";
else:
  _fl = CDLL(lib)   

if lib is None:
    raise ImportError, "Couldn't find the FluidSynth library."


# Helper function for declaring function prototypes

这个设置下工作得很好。


3

0

看起来你的猜测是正确的,这与fluidsynth.py有关。 你应该尝试将fluidsynth.dll放在系统库搜索路径中(最简单的方法可能是与你的脚本或fluidsynth.py相同的目录)。

我认为这个存档(通过谷歌发现)包含必要的win32二进制文件:http://svn.drdteam.org/zdoom/fluidsynth.7z


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接