SOLVED Audio percent?

Neptune

Member
I'm looking to get the percent an audio track is currently at. Basically this:
GML:
var percent = audio_current_time(audio) / audio_track_length(audio);
Do we have GM functions for doing this?
 

FoxyOfJungle

Kazan Games
The formula is:
Current_Value / Max_Value * 100

Look at: audio_sound_get_track_position()


GML:
// Create Event
music = audio_play_sound(snd_music,100,true);

// Step Event
percentage = audio_sound_get_track_position(music) / audio_sound_length(music) * 100;
 
Last edited:

AnotherHero

Member
Edit: Hi. I don't do a ton with audio in my games and I forget a few years ago they revamped the audio system. Did not know the code you were using were actually functions. @FoxyOfJungle answered your question.

The closest thing I'm aware GMS2 has is
Code:
audio_sound_get_track_position(audio);
I don't believe there's anything equivalent to "audio_track_length(audio)". One thing you could do, however potentially tedious, is manually add your track lengths in total seconds into an array or ds_list, so you could use
Code:
var percent = audio_sound_get_track_position(audio) / sound_lengths[| audio]
.

I'm not really sure if that would work. I'm just waking up :(

I did find this extension on the marketplace that might suit your needs: https://marketplace.yoyogames.com/assets/430/exaudio
 
Last edited:
Top