-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Way to calculate instantaneous AudioPlayer position? #118
Comments
The underlying implementation reads data from the source file in chunks defined by the |
Thanks for the reply, As for my use case, I'm developing a procedural generated rhythm game, and recently I've switched my spawning system to generate all objects you need to avoid before the song actually starts. This requires me pulling the precalculated positions every frame the game runs by providing it with the current time in the song. For people with good systems, this needs to be able to occur ~430 times per second (as current max refresh monitors are 360hz, and having a bit extra guarantees the smoothness won't ever break) |
any ideas on how to do this? |
In your case, particularly because you already know what all of your objects will be before the song starts, I'd recommend updating your own "play position" in your main game thread, since this is just a number that will have each frame's dt added to it. If you were very concerned about getting out of sync with the actual play position of the song, you could sync your play position with the one from the audio player by adding an audio listener that would be called with every block of samples the audio player reads. However, I suspect that you'll have to introduce some kind of latency to get the visuals to "feel" right with the actual sound coming out of the speakers. Like, the "play position" used by the game for visuals may actually need to run slightly ahead of or behind the play position of the audio player itself. |
I have an AudioPlayer and I need to pull the current song time very rapidly however
.position()
only updates ~60 times per second and I need it to be updated at least 300 times per second. It can work if I lower the sample rate to 128/256 or so but that brings in a quantity of other issuesThe text was updated successfully, but these errors were encountered: