python synthesize midi with fluidsynth

瘦欲@ 提交于 2019-12-01 01:14:25

问题


I can't import fluidsynth. [Maybe there's an better module?]

I'm trying to synthesize midi from python or pygame. I can send midi events from pygame. I'm using mingus, and it seemed pyfluidsynth would be good / easiest.

I think this means pyfluidsynth is installed, but a seperate fluidsynth was not. I don't know if it requires a 'fluidsynth' installer to work?

test.py:

import fluidsynth
print ":("

error:

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.

using: python 2.7-win32


回答1:


The python fluidsynth module is looking for the FluidSynth binary library file (ie fluidsynth.dll).

To get this you can download, compile and install http://sourceforge.net/projects/fluidsynth/files/fluidsynth-1.1.3/

OR

you may be able to find projects using fluidsynth (ie QSynth) which include precompiled copies of the .dll file.




回答2:


Yes you need the FuildSynth lib also (dll for windows).

To make it works with:

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

I've put everythings in the same directory (fluidsynth dll, PyFluidSynth Module, python script).

and changes the following lines in the pyFluidSynth modules (from line 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

It works fine with this setup.




回答3:


Looking at fluidsynth.py, your guess is probably right. You should try putting fluidsynth.dll somewhere in your system's library search path (the easiest would probably be the same directory as your script or fluidsynth.py).

I think this archive (found via google) contains the necessary win32 binary: http://svn.drdteam.org/zdoom/fluidsynth.7z



来源:https://stackoverflow.com/questions/5783913/python-synthesize-midi-with-fluidsynth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!