2011-04-25 96 views
6

我無法導入fluidsynth。 [也許有更好的模塊?]python與fluidsynth合成midi

我想從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. 

使用:蟒蛇2.7的Win32

+0

你有沒有試過https://github.com/MostAwesomeDude/pyfluidsynth? – endolith 2014-08-09 01:37:44

回答

0

看着fluidsynth.py,你的猜測可能是正確的。 您應該嘗試將fluidsynth.dll放在系統庫搜索路徑的某處(最簡單的可能與您的腳本或fluidsynth.py的目錄相同)。

我覺得這個檔案(通過谷歌找到)包含必要的Win32二進制:http://svn.drdteam.org/zdoom/fluidsynth.7z

3

是的,你還需要FuildSynth lib(dll for windows)。

爲了它的工作原理與:

  • 流體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 

它正常工作與此設置。