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
Handle asynchronous loading of audioClips #1022
Handle asynchronous loading of audioClips #1022
Conversation
Useful when audioclips are loaded asynchronously from discrete audio files
This should be generous (9 frames at 60 fps), and the maximum "acceptable" psychoacoustically according to https://gamedev.stackexchange.com/questions/74973/maximum-audio-delay-before-the-player-notices But most importantly, it puts an upper limit to the time we'll be spinning waiting for the audioclip to load, if somethings goes terribly wrong.
The QuestMachine also carries a DaggerfallAudioSource, I don't mind the call being changed to use that component's PlayOneShot() instead - it should be equivalent. |
Don't need to pass audioSource field as parameter to the coroutine
DaggerfallAudioSource takes a soundIndex and takes care of caching, should I get rid of clip field that is now only useful for preloading?
I didn't find any DaggerfallAudioSource in QuestMachine, only an AudioSource in PlaySound. |
I was referring to game object in scene. If you check the QuestMachine Inspector in Unity Editor, you'll see it's carrying a DaggerfallAudioSource component. So what you've done here is perfect. :)
|
Beginner's Luck ;) Any advice for the clip field I mentioned previously? |
Sorry I didn't answer. Yep, I think that should be fine now. :) |
Currently we can skip the first use of audioclips loaded from discrete files, because they're loaded asynchronously and may not be ready at the time of AudioSource.PlayOneShot().
See bug report https://forums.dfworkshop.net/viewtopic.php?f=24&t=1414
This patch wraps calls to PlayOneShot() with a coroutine so sound is played when ready, with a delay up to 150ms.
There's some code duplication here, could DaggerfallWorkshop.Game.Questing.Actions.PlaySound use DaggerfallWorkshop.DaggerfallAudioSource?