7

我无法导入流体合成器。[也许有更好的模块?]

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

我认为这意味着安装了 pyfluidsynth,但没有安装单独的流体合成器。我不知道它是否需要“fluidsynth”安装程序才能工作?

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

4

3 回答 3

3

是的,您还需要 FuildSynth 库(Windows 的 dll)。

使其适用于:

  • 流体合成器 1.1.6
  • python26(32位)
  • pyFluidSynth 1.1.4
  • 视窗

我把所有东西都放在同一个目录中(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

它适用于此设置。

于 2013-05-22T12:20:18.330 回答
3

python fluidsynth 模块正在寻找FluidSynth 二进制库文件(即fluidsynth.dll)。

为此,您可以下载、编译和安装http://sourceforge.net/projects/fluidsynth/files/fluidsynth-1.1.3/

或者

您可能能够找到使用包含 .dll 文件的预编译副本的流体合成器(即 QSynth)的项目。

于 2011-04-25T22:48:46.610 回答
0

看着fluidsynth.py,您的猜测可能是正确的。您应该尝试fluidsynth.dll在系统的库搜索路径中放置某个位置(最简单的可能是与您的脚本相同的目录或fluidsynth.py.

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

于 2011-04-25T22:46:25.917 回答