Problem "fluidsynth not found" thonny under ubuntu 24.04

Hello everyone,
I used scamp on my Ubuntu 20.04 laptop and it worked fine.
Now I moved to 24.04 (on the same laptop) and I have a problem with fluidsynth.

Description:

I follow the basic steps given on the home page, that worked perfectly on ubuntu 20.04 : installed scamp, abjad, rtmidi, pynput, lilypond from thonny. And then install fluidsynth from the ubuntu console with apt install command.

But it doesn’t work! Whatever I do, even just play a single piano note, I get the error message. Tried to reinstall, reboot… nothing worked out. I am quite puzzled.

I searched the web and no idea… So if any scampster is coming to help I’ll be very happy

Error printout: (from asking scamp to play a single piano note)

WARNING:root:Fluidsynth could not be loaded; synth output will not be available.


# The full code that resulted in the error:
```python3
from scamp import *
s = Session()
piano = s.new_part("piano")
piano.play_note(70,1,1)

the full error message:
WARNING:root:Fluidsynth could not be loaded; synth output will not be available.
Using preset Piano Merlin for piano
Traceback (most recent call last):
File “”, line 5, in
File “/var/data/python/lib/python3.12/site-packages/scamp/instruments.py”, line 186, in new_part
instrument.add_soundfont_playback(preset=preset, soundfont=soundfont, num_channels=num_channels,
File “/var/data/python/lib/python3.12/site-packages/scamp/instruments.py”, line 1010, in add_soundfont_playback
SoundfontPlaybackImplementation(bank_and_preset=preset, soundfont=soundfont, num_channels=num_channels,
File “/var/data/python/lib/python3.12/site-packages/scamp/playback_implementations.py”, line 328, in init
SoundfontHost(
File “/var/data/python/lib/python3.12/site-packages/scamp/_soundfont_host.py”, line 176, in init
raise ModuleNotFoundError(“FluidSynth not available.”)
ModuleNotFoundError: FluidSynth not available.

What happens if you open a terminal and type fluidsynth? Does it recognize the program?

Hi Marc,
thanks for the quick answer. It does but it seems to have a priority issue… here is the message

FluidSynth runtime version 2.3.4
Copyright (C) 2000-2023 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

fluidsynth: warning: Failed to set thread to high priority
Type ‘help’ for help topics.

fluidsynth: warning: Failed to set thread to high priority

I’m diving into this on the net.
I’ll come back if I have (or not) found a solution

Hi,

bad news… it took some time to make fluidsynth work. Now it does properly, the solution was to install Ubuntu Studio which enables realtime kernel. I tried to make a lowlatency kernel by hand but it did not work.

Anyway fluidsynth works properly from the terminal, but with the same basic script I get now a new error… python (or scamp) does not find fluidsynth. Tried to uninstall fluidsynth and I got the same error message! Is there a conflict with Ubuntu Studio? Should I uninstall it (actually it is just a simple way to install a lot of audio-related packages) and try to have a realtime kernel otherwise (but this seems it is trickier with the ubuntu 24.04).

Here is the error message:

WARNING:root:Fluidsynth could not be loaded; synth output will not be available.
Using preset Piano Merlin for piano
Traceback (most recent call last):
File “”, line 3, in
File “/var/data/python/lib/python3.12/site-packages/scamp/instruments.py”, line 186, in new_part
instrument.add_soundfont_playback(preset=preset, soundfont=soundfont, num_channels=num_channels,
File “/var/data/python/lib/python3.12/site-packages/scamp/instruments.py”, line 1010, in add_soundfont_playback
SoundfontPlaybackImplementation(bank_and_preset=preset, soundfont=soundfont, num_channels=num_channels,
File “/var/data/python/lib/python3.12/site-packages/scamp/playback_implementations.py”, line 328, in init
SoundfontHost(
File “/var/data/python/lib/python3.12/site-packages/scamp/_soundfont_host.py”, line 176, in init
raise ModuleNotFoundError(“FluidSynth not available.”)
ModuleNotFoundError: FluidSynth not available.

Tiny update. I ran a debug (found this on another topic) using this python code:

import logging; logging.getLogger().setLevel(logging.DEBUG)
import scamp

This is what I get:

DEBUG:root:Trying to load copy of pyfluidsynth from within SCAMP package.
DEBUG:root:Trying to load fluidsynth DLL/DYLIB from within SCAMP.
DEBUG:root:No local copy (not on mac or windows).
DEBUG:root:Loading of SCAMP’s copy of fluidsynth DLL/DYLIB failed.
DEBUG:root:Trying to load system copy of fluidsynth DLL/DYLIB.
DEBUG:root:Could not find system copy of fluidsynth DLL/DYLIB.
DEBUG:root:Loading of pyfluidsynth failed.
DEBUG:root:Trying to load system copy of pyfluidsynth.
DEBUG:root:Loading of pyfluidsynth failed again.
WARNING:root:Fluidsynth could not be loaded; synth output will not be available.

Okay, I remember encountering this issue before. It’s a problem with thonny, and specifically with an environment variable called LD_LIBRARY_PATH, which tells python where to look for the fluidsynth library. How did you install thonny? Through the installer? Through pip? I think it might be an issue when you use the installer on linux.

under Run>Configure Interpreter>General, I had this line in my environment variables:

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/home/marc/apps/thonny/lib

But I don’t think it’s needed anymore?

Hi Marc,
it works thank you very much!

I actually uninstalled Thonny and reinstalled it via the script they provide on their website. The first installation I made was through the Ubuntu dashboard (always the worst option ;-)).

The sound works, there is no more error message. But the actual sound is weird like if it was vibrating or like I has a square LFO tuned at a quite high frequency there…

Sorry to bother again. With the recent distros the sound is played by pipewire. I tried to switch back to pulse+jack but the issue was still there. Is there some setting to take care of?
I searched elsewhere but I did not find anything pointing this kind of problem.

Hi Marc,
I fixed it! It was a buffer problem for the soundcard. Moved it to 256 and now your wonderful program works perfectly fine.
I’m eager to play with that.
Thanks for your time and patience

That’s great! Also, remember that you can use new_midi_part or new_osc_part to drive playback from other programs on your computer.

Oh, and in case you’re interested I’m teaching a workshop starting this weekend!

Hi Marc,
sorry for the late reply. The workshop seems very interesting, but it’s a bit tight for my schedule right now. Maybe in the future!
Enjoy!