audio_system_is_initialised

This function returns whether the audio system (the main bus) is initialised on HTML5. For targets other than HTML5, this function will always return true.

On the HTML5 platform it is possible for the audio engine to not have finished loading on game start. Until it has, you should not do any of the following: 

NOTE This function differs from audio_system_is_available, which reflects the ability to play audio and depends on the state of the Web Audio context. The audio system has to be initialised first before it can be available.

Syntax:

audio_system_is_initialised();

 

Returns:

Boolean

 

Example:

 

Create Event

// Initially, the audio system is not initialised
audio_initialised = false;

em_emitter = -1;
bus_special_effects = -1;

Step Event

// Check until the system is initialised
if !audio_initialised && audio_system_is_initialised()
{
    audio_initialised = true;
    
    // First-time initialization
    bus_special_effects = audio_bus_create();
    bus_special_effects[0] = audio_effect_create(AudioEffectType.Reverb1);
    em_emitter = audio_emitter_create();
    audio_emitter_bus(em_emitter, bus_special_effects);
}

if (audio_initialised)
{
    // The audio system can be used here
    // ...
}

At the game's start, a variable audio_initialised is set to false in an object's Create event. In its Step event, the function audio_system_is_initialised is called for as long as audio_initialised remains false. Once the function returns true, the contents after the first if statement are executed: audio_initialised is set to true, which prevents further calls to the function, and a custom audio bus and emitter are set up. Once audio_initialised is true, the code of the second if statement is executed, which can be interaction with the audio system, e.g. changing effect parameters.