nwhitehead / pyfluidsynth

Python bindings for FluidSynth
GNU Lesser General Public License v2.1
198 stars 56 forks source link

wrong type error #2

Closed BrannonKing closed 7 years ago

BrannonKing commented 7 years ago

In attempting to use your script on FluidSynth 1.1.6, I get this error:

>>> fs = fluidsynth.Synth() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\Anaconda3\lib\site-packages\fluidsynth.py", line 192, in __init__ fluid_settings_setnum(st, 'synth.gain', gain) ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

I downloaded FluidSynth from here: https://sourceforge.net/projects/jorgan/files/fluidsynth/Fluidsynth%201.1.6%2064-bit/

tillahoffmann commented 7 years ago

If you are using python 3, the problem is that the second argument 'synth.gain' is a (unicode) string whereas CFUNCTYPE expects a byte string. We got it to run by using

fluid_settings_setnum(st, b'synth.gain', gain)

(note the b prefacing the argument).