G.SoundDuration

From GMod Wiki

Jump to: navigation, search
Function
Syntax SoundDuration( String sound_path )
Where is this used?
Description:
Returns the length of a sound in seconds.
Returns: Float
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.SoundDuration]G.SoundDuration [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionPrint the length (in seconds) of the sound.
Used onNewerShared.png
Code
print( SoundDuration( "npc/metropolice/pain1.wav" ) )
Output0.55986392498016


Notes

This seems to fail on some dedicated servers for some reason. This can be remedied by appending "../../hl2/sound/" to your soundpath if you have issues.

For example:

DescriptionPrint the length (in seconds) of the sound.
Used onNewerShared.png
Code
MySound = Sound( "npc/metropolice/pain1.wav" )
print( SoundDuration( "../../hl2/sound/" .. MySound ) )
Output0.55986392498016


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox