Add: Implement support for loading sounds in Ogg Opus format.#13055
Merged
PeterN merged 5 commits intoOpenTTD:masterfrom Dec 6, 2024
Merged
Add: Implement support for loading sounds in Ogg Opus format.#13055PeterN merged 5 commits intoOpenTTD:masterfrom
PeterN merged 5 commits intoOpenTTD:masterfrom
Conversation
Member
Author
|
Here is an Ogg Opus version of OpenSFX: |
glx22
reviewed
Nov 3, 2024
glx22
reviewed
Nov 3, 2024
SamuXarick
reviewed
Nov 3, 2024
Member
Author
|
Comparison of file sizes between .wav and .opus baseset:
|
rubidium42
reviewed
Nov 27, 2024
…viders. This is based loosely on TimerManager.
rubidium42
reviewed
Dec 5, 2024
…n memory. Sounds are loaded into memory on first use, using the SoundLoader interface to support format conversion. Sounds are retained in memory to avoid reloading every time a sound is played. This deduplicates WAV header parsing between NewGRF and baseset sounds, and will allow different audio formats to be supported.
rubidium42
approved these changes
Dec 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
Uncompressed .wav files are quite large. Including high quality sounds in basesets and NewGRFs increases the size of these files, increasing download time and size.
If OpenTTD could load sounds with lossy compression then the file sizes could be smaller, or more sounds could be included.
Description
Implement support for Ogg Opus encoded audio files. This format was chosen because it is open and modern, and doesn't suffer some limitations of other formats (something like MP3 adds 25-50ms delay at the start)
This is achieved by breaking out the sound loading code into a provider interface, so that loading of different formats (raw, .wav and .opus) is self-contained.
Audio files are decompressed once on load, and remaining in an uncompressed form in memory until a game is ended or sound packs are changes.
As the framerate window already has a memory size column for AI/GS scripts, this is now used to show the memory used by audio samples. This part is not really necessary and could easily be removed.
This will require changes to catcodec, grfcodec and NML to actually support Ogg Opus sound effects.
This is based the original MP3 version that I wrote in March.
Limitations
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.