python用fluidsynth合成midi

2024-05-15 05:35:03 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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

我认为这意味着pyfluidsynth已经安装,但是一个单独的fluidsynth没有安装。我不知道它是否需要一个“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


Tags: theinpyimportlinefindpygamefile
3条回答

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

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

python fluidsynth模块正在查找fluidsynth二进制库文件(ie fluidsynth.dll)。

要获得这个,您可以下载、编译并安装http://sourceforge.net/projects/fluidsynth/files/fluidsynth-1.1.3/

或者

您可能可以使用fluidsynth(即QSynth)找到包含.dll文件的预编译副本的项目。

是的,您还需要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

这个装置很好用。

相关问题 更多 >

    热门问题