0

I am trying to use FluidSynth in a game that I'm working on, but I can't seem to get Fluidsynth to work properly. Whenever I try to import I get this:

>>> import fluidsynth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\site-packages\fluidsynth.py", line 35, in <module>
    _fl = ctypes.cdll.LoadLibrary("./libfluidsynth")
NameError: name 'ctypes' is not defined

I read that you can do some import command to get rid of the Ctypes error but when I try that this happens:

>>> lib = ctypes.WinDLL('C:\Python26\Lib\site-packages\libfluidsynth.dll')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

I'm aware that the win32 application error usually happens when you're trying to run an app that's not designed for the computer's processor, but the source I downloaded the libfluidsynth.dll from said it was for Windows 32.
I am using Windows 7 64 bit, and Python 2.6.
Also, I downloaded Python on my 32-bit computer, and also the pyFluidSynth package and the FluidSynth DLL itself, however it was telling me it couldn't find the FluidSynth library or something.

1 Answers1

0

When loading libraries, the library you're loading much match the architecture of the Python you are currently running.

Ensure that if your Python is 64-bit, that libfluidsynth.dll is 64-bit. Same with 32-bit. They must be the same.

You can identify whether your Python in 64-bit or 32-bit with this code:

>>> import platform
>>> print(platform.architecture()[0])
64bit
Alyssa Haroldsen
  • 3,652
  • 1
  • 20
  • 35
  • Oh, okay. I downloaded the 64-bit Fluidsynth DLL and the error went away. However, I'm still getting the ctypes error. – Devin Patrick Magruder May 10 '16 at 23:28
  • Sounds like a poorly designed package. How does [pyfluidsynth](https://pypi.python.org/pypi/pyFluidSynth) perform? If you can't switch to that, try adding `import ctypes` before the package. – Alyssa Haroldsen May 10 '16 at 23:30
  • I couldn't get pyFluidSynth to install or create an egg for some reason (even with easy install), so I don't know what's up with that. I'm trying to use simply Fluidsynth because of that. There's an egg info but I can't find the egg file. – Devin Patrick Magruder May 10 '16 at 23:44