garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

SoundDuration does not return the actual sound's duration

Open Dispenserim opened this issue 11 years ago • 7 comments

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.

Dispenserim avatar Mar 29 '14 12:03 Dispenserim

Does this actually fail on WAVs that have been properly cued, or give the real time?

ImperialCommunity avatar Mar 29 '14 20:03 ImperialCommunity

Gives correct time on Wavs, all other formats typically give 60.

TeddiO avatar Jun 29 '14 13:06 TeddiO

It does give the right value in the client side but not in the server side.

hanm13 avatar Sep 24 '17 20:09 hanm13

This may be on Linux, works on Windows locally

EDIT: It is

Kefta avatar Sep 26 '17 09:09 Kefta

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.

Снимок экрана от 2019-11-03 22-53-04

comminux avatar Nov 03 '19 19:11 comminux

If you are talking about a crash on the x64-86 branch, it would be a separate issue unrelated to this.

robotboy655 avatar Nov 03 '19 20:11 robotboy655

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.

yobson1 avatar Dec 19 '20 09:12 yobson1

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)

AhmedGitHub400 avatar Mar 17 '24 01:03 AhmedGitHub400

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.

robotboy655 avatar May 29 '24 16:05 robotboy655