Closed ycl309 closed 2 months ago
I have today struggled with this problem whilst running test2.py
from the repo.
My 'solution' (!) was to copy fluidsynth.py
into the test
folder and debug it in VS code.
https://github.com/nwhitehead/pyfluidsynth/blob/master/fluidsynth.py#L43 then works as expected
clean up any existing installation(s)
pip uninstall pyAudio
download fluidsynth as it is virtually impossible to build on Windows due to glib etc etc. https://github.com/FluidSynth/fluidsynth/releases/download/v2.2.5/fluidsynth-2.2.5-win10-x64.zip
unzip to somewhere such that /path/to/fluidsynth/bin can easily be added to the Windows path. Check it can be found i.e.
where fluidsynth
R:\apps\fluidsynth\bin\fluidsynth.exe
go here and get the correct wheel for your Windows (64|32) and Python versions https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
then install what was downloaded
pip install <path/to/pyaudioxxx.whl>
get some decent soundfonts (piano/strings/choir) and unzip into a folder close to the Python test files https://www.producersbuzz.com/category/downloads/download-free-soundfonts-sf2/
run the Python demos such that the SF2 filename has a path to a known good SF2 installation. E.g. In test2.py
sfid = fl.sfload("../sf2/piano/full grand.sf2")
A couple of students and I had a similar problem on Windows. It turned out that the fluidsynth.dll that pyfluidsynth is trying to find gets labelled fluidsynth-3.dll at install. a quick fix was to rename the .dll file. Or line 37 in pyfluidsynth could be amended to :
lib = find_library('fluidsynth') or find_library(‘fluidsynth-3’)
@craigvear I don't know if that fixes the original error ( @ycl309 could you confirm that?), but if this fixes it for you it might be a sensible contribution. Would you mind creating a quick PR so we can get this in? -Chris
will do - need permission from owner first.
We might need to ping @nwhitehead or @albedozero here.
I think it makes sense to adapt the code to match the fluidsynth binaries. The fluidsynth realease for windows contain a file named libfluidsynth-3.dll
, so we should import that
pyFluidSynth currently does look for libfluidsynth-3.dll
or libfluidsynth-3.so
, depending on what platform it is running on, as well as libfluidsynth-2
, libfluidsynth-1
, libfluidsynth
, and fluidsynth
, and binds to the first one it finds. These were all past versions of the FluidSynth shared library, and it seems that a goal of pyFluidSynth is to be compatible with as many versions of Fluidsynth as possible (although maybe that is a topic for Discussion), so it makes sense to add more permutations of the library name (within reason) if they really are out there in the wild.
@craigvear, where did you get the Windows version of FluidSynth that you're trying to use? There are several third-party software packages (e.g. QSynth) that compile their own version of FluidSynth and bundle it with their package, and one of these might be munging the library name. I haven't seen any that use fluidsynth-3
(i.e. with no lib
prefix), but if it's a commonly-used package it would be good search for their version of the lib.
Unfortunately I never could replicate the OP's issue - if I follow the instructions in the link everything works fine.
Hi all. I’ve tried to replicate the issue this morning installing Fs direct from the GitHub repo (as I did before), and a different solution/ problem came to light, which does indeed support @albedozero points above.
The issue is NOT within pyfluidsynth, but a confusing PATH issue. When I extract Fs to the recommended directory (C:\Users\me\install\fluidsynth-x64) and include in PATH, pyfluidsynth returns the Couldn’t find error. When I move bin out of the fluidsynth-x64 folder directly into ‘install’ folder it gets picked up, by pyFs.
sorry for all the confusion. bw Craig
See:
Windows X86: 'libfluidsynth-3' was loaded as C:\tools\fluidsynth\bin\libfluidsynth-3.dll.
@nwhitehead I think this can be closed.
I am going through the steps provided here https://ksvi.mff.cuni.cz/~dingle/2019/prog_1/python_music.html I have 64 bits fluidsynth installed, pyfluidsynth installed and
python setup.py install
executed. But for some reason, whenever in any python file I doimport fluidsynth
it raises the error given in the title.Helps appreciated