Firelight Technologies FMOD Studio API
Retrieves the length of the sound using the specified time unit.
FMOD_RESULT Sound::getLength(
unsigned int *length,
FMOD_TIMEUNIT lengthtype
);
FMOD_RESULT FMOD_Sound_GetLength(
FMOD_SOUND *sound,
unsigned int *length,
FMOD_TIMEUNIT lengthtype
);
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.
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.
Version 1.03.06 Built on Apr 17, 2014