GeekFunkLabs / fluidpatcher

A performance-oriented patch interface for FluidSynth
MIT License
123 stars 15 forks source link

Playing pad style presets can cause the Pi to cut out #28

Closed clendee closed 2 years ago

clendee commented 2 years ago

Hi,

I notice when playing 'Analog Pad' or other pad style presets, perhaps using too many fingers, ie pressing too many keys, the Pi will cut out. I thought the Pi 3B+ should be enough to handle that amount of throughput (or am I looking at this the wrong way).

Is there a way to limit the polyphony on certain presents to prevent this from happening?

From running htop, I notice that python3 /home/pi/squishbox.py is running two or three times. I presume this is some funky coding techniques. image

When I run squishbox.py from the command line I get: image

I notice you use jackd1 as the audio server in the background. Apparently the multithreading in jackd2 is much improved. Unfa gives a short explanation of the issue \ features of both here (Ive jumped it to the appropriate section of the video)

albedozero commented 2 years ago

I have to say I'm impressed you're able to hold that many keys at once. I had to switch my sustain pedal to toggle and hold down about 5 octaves worth of notes to get the audio to cut out. To be fair, the voice count depends on the soundfont and can go up a lot if you use lots of reverb or have synth.gain turned up. I've tested this before and thought it would be an edge case, but another user recently encountered the same problem. The solution is to set synth.cpu-cores to 4 and synth.polyphony to 128. FluidSynth drops the oldest notes when running out of voices, and these values seem to be sufficient that the Pi's processor doesn't max out and cut the audio. This works on a Pi 3B+, but a Pi 4 could probably do higher polyphony. You can add these settings to your SquishBox/squishboxconf.yaml file - check the latest version in the repository to see how.

I added some tweaks to the installer to allow realtime audio, which deals with the Failed to set thread to high priority messages. squishbox.py isn't running multiple times - the green entries in htop are threads spawned by the original process. FluidSynth spawns a few, the GPIO library has one, etc.

I experimented with using jackd2 a few months back and had lots of problems with instability and segmentation faults, but it seems to be working great now (there is a much newer version available), so I updated the installer to use that as well! To be clear, the JACK server only gets started if audio.driver is set to jack. There is some more JACK discussion over here: #26

clendee commented 2 years ago

Thanks for your comments and your willingness to explore the questions and ideas.

Now that I have built the Squishbox, I can get more stuck in to its capabilities. Here is my rendition of it. A friend of mine has a laser cutter and built the box out of 3mm board. Its quite study and fits neatly. My friend said he'd be happy to share his design for any interested parties. IMG_20211122_165239

I feel that when I tried a different power supply, I was having less issues with the cutting out of various patches, so perhaps it was power related.