This function plays any sound asset in your game using any combination of parameters.
NOTE An Audio Playback Ended event is triggered for the sound when it stops playing.
The function takes its parameters as a struct. Depending on the parameters that you provide, the function behaves like audio_play_sound, audio_play_sound_at or audio_play_sound_on. The only key that is strictly required in the struct is the sound key.
The full list of keys is as follows:
audio_play_sound_ext(params);
Argument | Type | Description |
---|---|---|
params | Struct | A struct containing the key-value pairs for each of the parameters that you want to set. The sound key is required and takes a Sound Asset as a value. |
audio_play_sound_ext({ sound: snd_ambience });
The above code plays a sound "snd_ambience". The sound instance gets a default priority of 0 and won't be looped. All other sound properties are default as they haven't been provided in the struct.
var _sound_params =
{
sound: snd_shot,
priority: 20,
gain: 1.2,
pitch: 2,
emitter: em_north_entrance
};
audio_play_sound_ext(_sound_params);
The above code first creates a temporary struct _sound_params. It stores the settings to play a sound "snd_shot" with a priority of 20, a gain of 1.2 and a pitch of 2 on an existing emitter em_north_entrance. It then plays the sound with those settings using audio_play_sound_ext.
var _sound_params =
{
sound: snd_shot,
pitch: 1.1,
position:
{
x: 100,
y: 100,
z: 20
}
};
audio_play_sound_ext(_sound_params);
The above code creates a temporary struct _sound_params. The struct stores the settings to play a sound "snd_shot" with a pitch of 1.1 at an x of 100, a y of 100 and z of 20. The sound is then played with those settings using audio_play_sound_ext.