Audio file length

BlitzMax Forums/BlitzMax Programming/Audio file length

CASO(Posted 2006) [#1]
How can the length of and audio file be found out? I've heard that I may have to find out the bit rate first and then do some math but I don't know where to find the bit rate either.


tonyg(Posted 2006) [#2]
Might be a better way but this works :
Local mysample:TAudioSample = LoadAudioSample("yourfile.ogg")
Print mysample.length
Print mysample.hertz
Local mysound:TSound = LoadSound(mysample)
PlaySound mysound
WaitKey()



skidracer(Posted 2006) [#3]
For 16 bit stereo waves the following should give time in seconds:

time#=float(length/4)/hertz

and for 16 bit mono:

time#=float(length/2)/hertz


CASO(Posted 2006) [#4]
I tried skidracer's idea but i got 25.17... for a 1:40 song

If you dont divide by 4 or 2 then it returns the right value.

Thanks tonyg and skidracer