Fluidsynth error on Big Sur/M1 machine

Hey there—this might not be a SCAMP issue per se, but does anyone know why I might be getting this error when I fire up a script written using SCAMP?

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

This is happening on a new machine running macOS Big Sur with an Apple M1 chip. Wondering if that might have anything to do about it? I’m also still on SCAMP 0.8.6 (because I’m a little nervous about updating Abjad).

Anyway, I’m just a bit unsure of how to troubleshoot this, so I thought see if this rings a bell for anyone on here. Thanks!

Yeah… it’s probably the M1 or Big Sur. Can you try installing
fluidsynth via homebrew?

I’m guessing you’ve used homebrew before, but if not here’s the
installation instructions: https://docs.brew.sh/Installation

SCAMP comes bundled with an old version of fluidsynth, and I’m not
surprised that it’s causing issues, to be honest. Hoping that the
homebrew version works!

(Let me know how it goes — I’d like to know how to get things up and running on an M1/Big Sur machine)

That didn’t do the trick, sadly. I tried installing via homebrew but it told me that the most recent version of fluidsynth was already installed. For good measure I went ahead and reinstalled the whole thing with homebrew. Still got the same error when I ran my SCAMP script, though. :frowning_face:

Have you tried installing the Intel-based homebrew using rosetta? Perhaps this is helpful?

Oh, also, what happens of you run fluidsynth from the terminal? And what happens if you run:

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

It should print some useful messages.

Oof, okay, this has been a bit of a saga, but I think I’ve got it working now. First of all, thank you so much for the suggestions, Marc—they were extremely helpful.

So the first thing I did was run those three lines of debug code with the M1 versions of homebrew/fluidsynth installed, and I got this:

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:Encountered error during load: ‘dlopen(/Users/aes/.virtualenvs/comp/lib/python3.9/site-packages/scamp/_thirdparty/libfluidsynth.1.5.2.dylib, 6): no suitable image found. Did find:
/Users/aes/.virtualenvs/comp/lib/python3.9/site-packages/scamp/_thirdparty/libfluidsynth.1.5.2.dylib: no matching architecture in universal wrapper
/Users/aes/.virtualenvs/comp/lib/python3.9/site-packages/scamp/_thirdparty/libfluidsynth.1.5.2.dylib: no matching architecture in universal wrapper’
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.

The “matching architecture” message seemed very telling, so then I tried installing the Intel homebrew, and then fluidsynth via that homebrew, using the steps in the Medium post you linked. That gave me this:

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:Loading of SCAMP’s copy of fluidsynth DLL/DYLIB succeeded.
DEBUG:root:Loading of pyfluidsynth succeeded.
Testing for working audio driver…
fluidsynth: error: Couldn’t find the requested audio driver alsa. Valid drivers are: coreaudio.
fluidsynth: error: Error setting the audio callback. Status=-66748
fluidsynth: error: Couldn’t find the requested audio driver dsound. Valid drivers are: coreaudio.
fluidsynth: error: Couldn’t find the requested audio driver Direct Sound. Valid drivers are: coreaudio.
fluidsynth: error: Couldn’t find the requested audio driver oss. Valid drivers are: coreaudio.
fluidsynth: error: Couldn’t find the requested audio driver pulseaudio. Valid drivers are: coreaudio.
fluidsynth: error: Couldn’t find the requested audio driver jack. Valid drivers are: coreaudio.
fluidsynth: error: Couldn’t find the requested audio driver portaudio. Valid drivers are: coreaudio.
fluidsynth: error: Couldn’t find the requested audio driver sndmgr. Valid drivers are: coreaudio.
WARNING:root:No working audio driver was found; synth output will not be available.

Which was different, at least. The “Status=-66748” thing led me here, where a few fluidsynth users are speculating that Core Audio has some sort of permissions-related issue on Big Sur: https://www.mail-archive.com/fluid-dev@nongnu.org/msg05491.html

So I figured that maybe the path of least resistance was to try to get fluidsynth to use a different audio driver. I installed portaudio (or maybe it was already installed, but it was just being masked from me at the time?), but I kept getting the same errors as above—the only “valid driver” being printed out was coreaudio and I was being told that portaudio couldn’t be found despite the fact that I had just installed it.

Finally I realized that maybe the problem was with the fluidsynth dll’s/dynlib’s in SCAMP’s _thirdparty folder. I tried deleting those, and voila! It worked. I can get synth playback from SCAMP now. I guess maybe SCAMP’s older, local version of fluidsynth was hard coded to only accept coreaudio, or something? Not sure. Anyway, I have sound now!

Hopefully this will be helpful to others, especially as the M1 chip continues to roll out… thanks again for all of the help, Marc!

1 Like

Oh weird! Had you installed Rosetta 2 before, or did you do it in the process of installing the Intel-based homebrew?

If so, it sounds like maybe before you installed Rosetta 2, it couldn’t load the Intel-based copy of libfluidsynth packaged with SCAMP. And then, once you installed Rosetta2, it was able to load it but ran into some other error with that (fairly old) copy of libfluidsynth.dylib. Then, once you deleted those dylibs, it just loaded the more modern version you installed using Homebrew (intel-based), which now works. Maybe?

By the way, you don’t have to delete the dylibs: all you actually have to do is run:

import scamp
scamp.playback_settings.try_system_fluidsynth_first = True
scamp.playback_settings.make_persistent()

This makes SCAMP try the system copy before the one bundled with scamp. (See http://scamp.marcevanstein.com/scamp/scamp.settings.PlaybackSettings.html?highlight=playbacksettings#scamp.settings.PlaybackSettings)

Anyway, so glad you got it working! I may have more questions for you in the future, since I want to make things as seamless as possible. :slight_smile:

Yeah, I think that’s probably pretty much exactly what happened. I hadn’t installed Rosetta 2 before running into the original error and going through this process, no. I think there probably really is some sort of issue with Core Audio on Big Sur, though—I didn’t clarify this, but I was getting that permissions error even when I fired up the up-to-date fluidsynth directly from my Rosetta terminal. (It wasn’t just a matter of my SCAMP script falling back on an older version of fluidsynth, in other words.)

Thanks for the tip re: the playback settings—that is very handy and much better than my shoestring-and-bubblegum approach of just moving the files. :wink: And thanks again for the help. I definitely felt like I was grasping around in the dark on this one and needed a good push in the right direction. Feel free to fire away with questions anytime!!