[Audio V2] sound.onPlayObservable missing and audioEngine.unlockAsync demo missing

Hi, @docEdub

I noticed that the audio engine is missing an observable like onPlayObservable, which could be useful to trigger something at the exact moment a sound starts. For example, in my case, I want to display a GUI window precisely when the Game Over sound plays, so they are perfectly synchronized.

Also, I noticed that in the PG demos in the documentation, audioEngine.unlockAsync hasn’t been updated to reflect this change. Previously, the demos used audioEngine.unlock, but now it has become unlockAsync. As a result, none of the PG demos in the documentation work anymore:

Thank you.

Thanks, I’ll fix the docs but I’m not sure triggering GUI items on a sound’s state is a good idea since the audio engine may be locked and the observable may not get triggered as a result. I’d recommend triggering GUI items and they’re related sounds from your own code at the same time, instead.

What I wanted to do was to display a Game Over text in a rectangle just as the sound would be triggered?

Because when I do as you say, there is a slight delay between the sound and the display of the Game Overs. Nothing too bad, I thought an onPlayObservable would do the trick.

I’m not talking about an observable at the time of play, but at the moment when the sound is triggered. But it doesn’t matter if it’s not recommended.

Thank you

There shouldn’t be a delay with the sound’s play function. The sound should play immediately. Does the sound you’re using have a fade in or short silence at the beginning? …or maybe the sound is not being created beforehand? Creating a sound takes a little time, but there shouldn’t be any delay with play function itself.

Ah yes, it is not generated beforehand. I do it on the fly. I should charge it beforehand indeed.
Thank you.

1 Like