audio: revive the opus package
Operating System
- Windows
- macOS
- Linux
- FreeBSD
- OpenBSD
- Android
- iOS
- Nintendo Switch
- PlayStation 5
- Xbox
- Web Browsers
What feature would you like to be added?
Bring back audio/opus, providing Decode and DecodeF32 for Opus streams alongside audio/vorbis and audio/mp3.
The package was added in #3393 and removed as part of #3621, so the API, its tests, the Opus mode in examples/audio, and the ragtime.opus sample under examples/resources/audio can all be restored from history. What is missing is a decoder that is sound on every supported platform:
- It must work on 32-bit platforms. The previous backend
github.com/kazzmir/opus-gois transpiled C generated forlinux/amd64that writes struct fields through hardcoded byte offsets. On any 32-bit GOARCH its range decoder never leaves its normalization loop, so the first packet of every stream spins at 100% CPU forever (#3621, kazzmir/opus-go#15). - It must have no other critical issues.
Possible directions: an upstream fix in kazzmir/opus-go, another pure-Go Opus decoder, or a decoder written for this repository.
Whichever backend is chosen, a decoding test that runs on a 32-bit GOARCH should come with it, so a hang of this kind cannot reach a release again.
Why is this needed?
Opus is a common choice for game audio: it is royalty-free, and at the bit rates games use it is smaller than Vorbis or MP3 at comparable quality. Ebitengine decodes Ogg/Vorbis, MP3 and WAV, and Opus is the remaining gap.
Opus support was never part of a stable release: it existed only in the v2.10.0 alpha tags, from v2.10.0-alpha.11 until the removal, so no released version regresses.
Filed by Claude (Claude Code), on behalf of @hajimehoshi.
Source: hajimehoshi/ebiten