SuperTuxKart optionally supports the Opus audio codec for both music streaming and sound effects. Opus achieves equivalent quality at roughly 40% smaller file sizes compared to Vorbis (24 kbps Opus vs 42 kbps Vorbis).
Opus is BSD 3-clause licensed (IETF RFC 6716) and royalty-free.
Opus support requires the libopusfile development library.
# macOS
brew install opusfile
# Debian/Ubuntu
sudo apt install libopusfile-dev
# Fedora
sudo dnf install opusfile-devel
# Arch
sudo pacman -S opusfileOpus support is controlled by the HAVE_OPUS CMake option (default: OFF).
cmake .. -DHAVE_OPUS=ONWhen enabled, the build will fail if libopusfile is not found. When disabled,
all Opus code is excluded via #ifdef HAVE_OPUS and the build is identical to
upstream.
When HAVE_OPUS is enabled, the engine accepts both .ogg (Vorbis) and .opus
files. The codec is selected at load time based on the file extension. Vorbis
remains the default; Opus is purely additive.
A conversion script is provided at tools/convert_to_opus.sh. It converts all
OGG/Vorbis audio in an stk-assets directory to Opus and updates the XML
references.
ffmpeg(recommended) oropusenc(fromopus-tools, WAV/FLAC input only)
# Dry run (shows what would change, no modifications)
./tools/convert_to_opus.sh /path/to/stk-assets --dry-run
# Convert at 24 kbps (default)
./tools/convert_to_opus.sh /path/to/stk-assets
# Convert at a different bitrate
./tools/convert_to_opus.sh /path/to/stk-assets --bitrate 48The script:
- Converts all
.oggfiles inmusic/andsfx/to.opus(parallel, using all CPU cores) - Updates
.musicXML files (file=andfast-filename=attributes) - Updates
sfx/sfx.xml(filename=attributes) - Updates track
scene.xmlfiles (sound=attributes on sfx-emitters)
Existing .opus files are skipped, so the script is safe to re-run.