Determine total sound playing length (ms)

BlitzMax Forums/BlitzMax Beginners Area/Determine total sound playing length (ms)

SuperStrict

Local sample:TAudioSample = LoadAudioSample("battle.ogg")
Local length:Float = getSampleLength(sample)
Print "Length in seconds: " + length
Print "Length: " + Int(Floor(length/60))+"m "+Int(length Mod 60)+"s"
Local sound:TSound = LoadSound(sample)
Local channel:TChannel = PlaySound(sound)
While channel.playing()

Wend

Function getSampleLength:Float(sample:TAudioSample)
	Return Float( (sample.length / Float( (sample.hertz * 60) ) ) * 60)
End Function