Sound in java: Best practice 2022

I can’t edit the post on the linked thread anymore, the only thing I’d change now is in regards to point 1; it’s been a longtime since the Pulseaudio interface has been deprecated and as of now I’d run with audio-playback and audio-record exclusively.

Otherwise, nothing else has changed since.

Tl;Dr

  • Correct interfaces (audio-playback)
  • Use extensions to get the socket setup
  • If Java 8, stage libpulse (might be in the newest extensions automatically?)
  • If Java 9+, additionally stage alsa, use layouts and ALSA_CONFIG_PATH variable to use alsa-pulse backend.

This isn’t particularly a Java specific problem, the only Java nuance here, is that Java 8 from the Ubuntu/Debian repositories has native Pulseaudio support whereas 9+ do not, and this can be confusing since you’d usually assume newer versions would have more features/compatibility but isn’t true in this specific scenario.