audioanalyzerstore

AudioAnalyzer From Sync to Async

Now we can use asynchronous initialization nodes to avoid the program hang during a long audio decoding process.

sync_initialization
Player synchronous initialization

To convert our project from sync to asynchronous initialization we need to start moving all the code that need to be after the initialization to the event that will be triggered when the initialization of the player ends.

async_init_end

The delegated event returns a boolean with the initialization result equals to the synchronous initialization node.

The Bind of the event must be called before the Async Player Initialization node

async_init_start
async_initialization
Player asynchronous initialization

With this modification we can avoid the game freeze moment when a big audio file is decoded, and continue doing more thing during the player initialization or add a loading screen.

Adding a decoding widget

We can add a widget, like a loading screen, to know when the audio decoding is running.

decoding_widget
Decoding screen design

We can Add to Viewport the widget just after the Async Init Player Audio call. This will fill the screen with the decoding widget until the initialization process ends.

decoding_widget_start

To remove the widget from the screen we need to Remove from parent our widget on the delegate event of OnInitPlayerAudioFinished event.

decoding_widget_end
decoding_audio_level

Support this blog!

For the past year I've been dedicating more of my time to the creation of tutorials, mainly about game development. If you think these posts have either helped or inspired you, please consider supporting this blog. Thank you so much for your contribution!