-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Audio playback progress times are not updated in real time #71122
Comments
This is known and expected behavior. You can read more about it in the documentation, here: https://docs.godotengine.org/en/stable/tutorials/audio/sync_with_audio.html I doubt there is a simple way to completely eliminate this. It's a side-effect of how audio streaming works in pretty much any modern engine. (And possibly other software as well; I'm not an audio expert.) You'll get similar results in engines like Unity and Game Maker, for example. While it's kind of an annoying quirk of audio systems, it is not a bug, and you can work around it just fine. Examples of how to do this are also in the link above. |
Ah, fair enough! It certainly used to have the same quirk for playing audio, but it's been a while since I used GameMaker, so it's very possible they updated it to avoid that somehow. It's also possible that the delay in updates doesn't happen in GM when sound resources use the non-streamed or compressed settings, but the trade-off there will be a much higher memory and/or CPU use, and much longer load times. I think "Uncompressed" is the default for sounds in GM, which could explain why you didn't see the same issue in your test.* (Edit: Welp, guess that wasn't the cause after all. Not sure why GameMaker behaves differently then...) I believe Godot streams all its audio from disk. If you'd like the option to store it in memory for faster and more reliable playback in Godot, (assuming that's the solution) perhaps it's worth submitting a proposal. *(I'm making a lot of guesses here, since I don't currently have a copy of GameMaker installed to test this for myself. Feel free to correct me if I'm wrong!) |
So will it be fixed? |
It depends on if it is considered a bug, or just how things work, I would recommend the suggestion above to make a proposal for audio being stored in memory to get around this, which would be more flexible. The current implementation is likely the way it is for a reason, that having the stream position update every frame might not be cheap to accomplish for all cases and the choice was made to make it more efficient and performance focused. The Godot engine and the community is a volunteer effort, with people working on what they want and are able to, on their own schedule. While major bugs are focused on and we try to fix them as soon as possible there aren't any guarantees that this thing or that will be fixed in a timely manner. And you need to recognize and respect that. |
Sorry, I was just wondering if this is in the plan to be solved , without rushing to resolve it as soon as possible. |
Thank you, I wanted to point this out given some comments I've seen from you, I'm sorry if this has been due to language barrier |
You can calculate the actual frame perfect audio playback progress by adding the time since the last mix (playback_position updates every mix) func get_actual_playback_position():
return get_playback_position() + AudioServer.get_time_since_last_mix() * pitch_scale |
Does it hurt graphics performance a lot if we have Godot calculate audio progress on every frame, for higher precision? Or maybe it can be a setting in the editor, to improve the precision for audio apps/games? It would be cool if Godot engine allowed for more precise audio apps & games, even if it needs to be enabled via a checkbox in the settings. :-) |
The following is a poorly educated suggestion because threads may come into play here. |
Godot version
3.5.1mono
System information
windows10
Issue description
Audio playback progress times are not updated in real time.They are updated only every two to three frames.This is prone to errors in timing and need to be fixed.
Steps to reproduce
Run my test project
Check the console
Each output is found to be repeated two to three times
Minimal reproduction project
(https://github.com/godotengine/godot/files/10375421/Audio.Time.Update.Test.zip)
The text was updated successfully, but these errors were encountered: