Sound keeps rapidly cutting in and out

Issue: sound is choppy on my sketches

About a year ago I switched laptops and imported all my sketches over, including a few that use the Sound library. Said library works fine on my previous laptop, as well as every other computer I use, but not on this one. And meanwhile, for this laptop, audio seems to work fine for seemingly every other application (i.e. videos in browser, Steam games, notification sounds, etc.), just not with Processing sketches. So this seems not to just be an issue with Processing, or just an issue with my computer, but specifically with them working together in tandem. Also, this issue persists regardless of if I use Processing 3.5.4 or Processing 4.3.

The specific issue is that, throughout the course of a sketch running, the sound will work fine for a while, then start being choppy, then work fine again. As can be seen in the video below, the issue appears to be that the application is rapidly turning off and on its sound several times per second, as is evident through the sound mixer repeatedly changing its mind as to whether there is or isn’t an application using sound.

This appears to be the case for all sketches I run with the Sound library, by the way. I also tried connecting it to other devices (HDMI to my TV, bluetooth to my speakers), but the problem still persists. I also tried uninstalling and reinstalling the Sound library, but it didn’t change anything.

It should be noted that I’m running this on Linux Mint, but I don’t think this is specifically the operating system’s fault, as my last laptop is also Linux Mint but was completely compatible with Processing and its Sound library. But since I don’t know which half of this is causing the issues (Processing or Mint), I also posted this to the Linux Mint forums.

Also, not sure if this is relevant, but another thing I had to do with this device was that, for any sketch that uses P2D or P3D, I have to now include this at the top of sketches:

void settings() {
  System.setProperty("jogl.disable.openglcore", "false"); //get the thing to work properly
  size([width], [height], [renderer]);
}

Because otherwise the sketch would have a runtime error upon trying to start up. This is also an issue I’ve only had with this laptop. Not sure if that’s at all relevant, but thought it was at least worth mentioning.

Any help would be greatly appreciated. If my problem is solved on the other forum, I’ll be sure to make a post explaining what it was and to mark it as solved.

Thank you!

1 Like

Hello @Math_Machine! Welcome back to the forum :slight_smile:

Could you let us know which version of the Sound library you’re using?

cc @kevinstadler

Thanks for reporting this issue! There have been reports of other users having choppy/stuttering sound issues on Linux Mint recently, so I’m suspecting it is something to do with the default audio routing setup on Mint. As far as I know Mint should be running PulseAudio, so I’m confused why your graphical mixer is showing “ALSA plug-in” – it might be a hint that the Java Runtime (JRE) is trying to use ALSA directly, and ends up in a tug of war with PulseAudio over who gets access to the soundcard.

It could be that some .asoundrc magic might do the trick, the other solution would be to try running the sketch on a different Java runtime. I don’t think changing the Java system installation will have any effect on that (unless Processing’s JRE makes use of the underlying system’s JavaSound plug-ins??). The upcoming Processing release should contain some updates on the bundled JRE, I’m not sure if there are already some alpha releases floating about that could be tried out @ProcessingOrg ??

(This .asoundrc workaround is from 2007 but might still be worth a shot…)

1 Like