Firelight Technologies FMOD Studio API
Sound::getLength
Retrieves the length of the sound using the specified time unit.
C++ Syntax
FMOD_RESULT Sound::getLength(
unsigned int *length,
FMOD_TIMEUNIT lengthtype
);
C Syntax
FMOD_RESULT FMOD_Sound_GetLength(
FMOD_SOUND *sound,
unsigned int *length,
FMOD_TIMEUNIT lengthtype
);
C# Syntax
RESULT Sound.getLength(
out uint length,
TIMEUNIT lengthtype
);
JavaScript Syntax
Sound.getLength(
length, // writes value to length.val
lengthtype
);
Parameters
- length
- Address of a variable that receives the length of the sound.
- lengthtype
- Time unit retrieve into the length parameter. See FMOD_TIMEUNIT.
Return Values
If the function succeeds then the return value is FMOD_OK.
If the function fails then the return value will be one of the values defined in the FMOD_RESULT enumeration.
Remarks
Certain timeunits do not work depending on the file format. For example FMOD_TIMEUNIT_MODORDER will not work with an mp3 file.
A length of 0xFFFFFFFF usually means it is of unlimited length, such as an internet radio stream or MOD/S3M/XM/IT file which may loop forever.
Warning! Using a VBR source that does not have an associated length information in milliseconds or pcm samples (such as MP3 or MOD/S3M/XM/IT) may return inaccurate lengths specify FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCM.
If you want FMOD to retrieve an accurate length it will have to pre-scan the file first in this case. You will have to specify FMOD_ACCURATETIME when loading or opening the sound. This means there is a slight delay as FMOD scans the whole file when loading the sound to find the right length in millseconds or pcm samples, and this also creates a seek table as it does this for seeking purposes.
See Also
Version 1.10.03 Built on Feb 1, 2018