garrysmod-issues
garrysmod-issues copied to clipboard
SoundDuration does not return the actual sound's duration
Regardless of sound format.
Most of the time it returns a value that you need to multiply by 4.5 in order to get it's approximate duration, sometimes it returns 60 and very rarely returns 0.
Does this actually fail on WAVs that have been properly cued, or give the real time?
Gives correct time on Wavs, all other formats typically give 60.
It does give the right value in the client side but not in the server side.
This may be on Linux, works on Windows locally
EDIT: It is
6adf529c-604f-4c0d-a5563490-cb727dd4.txt
Can my log file be related to this error? Tested on Arch Linux with x86-64 branch. Also, I know how to produce it and will share if interestingly.

If you are talking about a crash on the x64-86 branch, it would be a separate issue unrelated to this.
https://github.com/yobson1/glua-soundduration Made this to replace the included function, right now only supports MP3s and isn't extensively tested so it might not work on every MP3 file out there, but anyone can feel free to give it a try if they need it.
He really doesn't get the timing right from the sound
But I discovered a solution to this matter, you can use (sound.PlayFile) to get the correct timing of the sound
sound.PlayFile("sound/".. YourSound, "noplay",function(igac, errorId, errorName)
if (IsValid(igac)) then
local length = igac:GetLength()
print(SoundDuration(YourSound) ,length)
end
end)
It should be fixed on dev beta for the most part for .wav and .mp3 files on both srcds and client, and on linux and windows.