audio_sound_length

Returns the length of the indexed sound.

Syntax:

audio_sound_length(index);


Argument Description
index The index of the sound to check.


Returns: Real


Description

This function will return the length of the given sound in seconds. The sound can either be a referenced from index for an individual sound being played which has been stored in a variable when using the audio_play_sound or audio_play_sound_at functions, or an actual sound asset from the resource tree.


Example:

var len;
len = audio_sound_length(snd_Beam);
audio_play_sound(snd_Beam, 1, false);
alarm[0] = room_speed * len;

The above code gets the length (in seconds) of the sound indexed in the variable "snd_Beam", then plays the sound and sets an alarm to go off when the sound has finished playing using the length of the sound to calculate the time needed for the alarm.


Back: Audio
Next: audio_sound_pitch
© Copyright YoYo Games Ltd. 2018 All Rights Reserved