-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to decode Ogg Vorbis at load time to save space and have good performance #1144
Comments
What do you estimate would be the savings in disk space comparing OGG and WAV for sub 3 second long sounds. Assuming reverb tails are already stripped. |
@jitspoe Have you measured the performance impact of using Ogg Vorbis sounds in your project? Is it significant enough to warrant doing this? Maybe you can use Ogg Vorbis for music and ambient tracks only and keep using WAV for the rest. The compression gains are generally not as interesting in shorter samples. |
@TheDuriel It looks like the wav files are about 4-8x larger for short sounds like footsteps. I actually have a bunch of larger ambient sounds like wind and rain and thunder that I'd like to layer together. @Calinou I'm not sure what the perf hit for ogg vorbis is. I haven't actually done a profile. I was just basing this off of the documentation: https://docs.godotengine.org/en/stable/tutorials/audio/audio_streams.html I'd be interested to test on mobile, but I haven't gotten a build for that, yet. I'd like to have possibly 20+ sounds layered, which I have a feeling would start impacting performance on low-end hardware. If it doesn't have a significant impact, the documentation should probably be updated. :) |
I created a test project with 600 stream players that can switch between wav and ogg. The audio thread has spikes at a regular interval at around 17-19ms for wav and 80-85 for ogg (where it's doing the mixing, I assume). In short, ogg is about 4-5x slower than wav. Not sure if that'll have much of an impact in a realistic scenario, since it's already in its own thread, unless cores are limited. Once you hit a certain threshold, though, the sound gets choppy. Here's the project: Space bar switches between ogg and wav streams. |
Note that lossy WAV is an alternative that can be explored if Ogg Vorbis or even MP3 decoding are too expensive in your project. It's compatible with any program that can read WAV files, without requiring dedicated support. |
The Rocket Bot Royale post mortem mentions perf issues decoding a bunch of ogg files and implemented a "Decode once" option, which I think is a great (and tested) solution. godotengine/godot#62291 Also just realized I never answered TheDuriel's question. I have a mix of ogg and wav files for footstep sounds. Wav files average around 40KB. Ogg vorbis files average around 8KB, so that's about a 5x difference on really short sounds. Probably a lot more on longer sounds with quiet sections that can benefit from VBR and such. Also depends on the compression rate. |
I think that can be a great feature and I was searching for ways to get something like that for me as well and found this proposal. I have players with a bit weaker CPU where the audio could not keep up the pace at some locations (audio seems to be single core, so more cores does not really help) with around 80-120 AudioStreamPlayer 2D/3D tested on Godot 3.5. I'm currently reducing the number but as well reduce the decoding load. I've hit the wall on my machine with ogg with around 520 AudioStreamPlayer3D at 4.4GHz CPU where it takes up 100% of one core without any special effects. But as realistically the CPU is busy with other things as well and may has a lower CPU frequency, only a part of this is possible I think. With this proposal the advantages of small disk space and low decoding load for frequent sounds can be combined on the cost of RAM. |
Dear @jitspoe, why did you choose Vorbis over the next development of the same team, Opus? And are you familiar with the relatively new lossy QOA format? Its author, @phoboslab, emphasizes the decoding speed, especially in games.
|
@sergeevabc Godot lacks support for Opus, hence this proposal focusing on Vorbis only. Regarding QOA support, see #7599 where it was mentioned in passing. It's more of a replacement for IMA-ADPCM compression (which is simplistic but low-quality) than complex lossy formats like Vorbis and Opus. |
Just a note: my statement about it having a better quality than Vorbis at max bitrate was wrong. It's actually comparable to it on lower bitrates like 96kbps with a bit of noise. Regardless, it's still much better than IMA-ADPCM and the quality loss is pretty acceptable, unless you're an audiophile listening with Hi-Fi headphones. |
And it's supported now, for those interested :) While it does not add the "option to decode Ogg Vorbis at load time", it is something to "save space and have good performance". |
Closing, as QOA support effectively supersedes this by providing lossy audio compression with very low CPU requirements (lower than MP3). QOA is most suited to sound effects and ambience, but it can technically be used for music as well (although Ogg Vorbis remains a better tradeoff here). |
Describe the project you are working on: 2.5d Platformer (Fist of the Forgotten)
Describe the problem or limitation you are having in your project: I'd like to use ogg vorbis files for all sounds to keep the file size down, but I don't want to impact runtime performance.
Describe the feature / enhancement and how it helps to overcome the problem or limitation: Decoding ogg files at load would allow the file size to remain small and not decoding in realtime will allow the performance to be better when playing lots of sounds.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: This would probably make the most sense as an import checkbox. Like [] Decode sample into memory on load.
If this enhancement will not be used often, can it be worked around with a few lines of script?: No.
Is there a reason why this should be core and not an add-on in the asset library?: Not sure if this can be done as an add-on. Seems pretty engine-level.
The text was updated successfully, but these errors were encountered: