Documentation: Sound compatibility recommendations
Documentation request:
What documentation needs to be added?
Information on maximizing cross-platform compatibility for sound assets.
Where should it be added?
Probably the programming guide.
Details
Switching from soloud to pyglet for sound means that we inherit pyglet's issues. On OpenAL backends, only 16 bit audio is supported. Linux users can switch to a pulse backend, but macs reportedly only support 16 bit:
Your audio files are 24bit, but unfortunately the OpenAL backend does not support that. Linux also has a PulseAudio backend available, but for OSX it only has OpenAL. Essentially you need to use 16bit audio files for cross platform support.
A user ran into this on the pyglet discord server, and our users may be more confused by this as beginners. An easy recommendation would be to import assets into Audacity and export as 16 bit PCM wav, which is the default setting for wav export.
Perhaps we should prioritize PulseAudio over OpenAL by default?
We could, but that wouldn't address the issue for mac users.
Yeah I still think we should recommend those default WAV settings. That’s going to be by far the most universally usable format.
But perhaps using PulseAudio by default stops the issue for a handful of people, and doesn’t really have a downside I can think of
Will it fall back to OpenAL if Pulse fails for whatever reason?
Yeah there is a tuple in sound.py and the order of that is the priority. It can be overridden by users but OpenAL is the default priority
As an update to this issue, some distros are switching to PipeWire as their default rather than PulseAudio. It has a Pulse Audio compatibility mode so we may not need to do anything to ensure compatibility, but in the future we might want to prioritize it when available.
@pushfoo I have been running Pipewire with Pyglet/Arcade for close to two years and it just works out of the box. Almost nothing supports PipeWire natively, the PulseAudio compatibility it offers is pretty much flawless though.
Just a note that the only reason OpenAL is the only backend for Mac is because it's the only one that supports positional sound on Mac. While another could be added that supports 24 bit, it would cause a small discrepancy between drivers.
Perhaps we should prioritize PulseAudio over OpenAL by default?
Given https://github.com/pyglet/pyglet/issues/952, I think we should do the opposite, or at least recommend pipewire-pulseaudio if OpenAL isn't an option for a Linux user.