Firelight Technologies FMOD Studio API
Sound::setLoopPoints
Sets the loop points within a sound.
C++ Syntax
FMOD_RESULT Sound::setLoopPoints(
unsigned int loopstart,
FMOD_TIMEUNIT loopstarttype,
unsigned int loopend,
FMOD_TIMEUNIT loopendtype
);
C Syntax
FMOD_RESULT FMOD_Sound_SetLoopPoints(
FMOD_SOUND *sound,
unsigned int loopstart,
FMOD_TIMEUNIT loopstarttype,
unsigned int loopend,
FMOD_TIMEUNIT loopendtype
);
C# Syntax
RESULT Sound.setLoopPoints(
uint loopstart,
TIMEUNIT loopstarttype,
uint loopend,
TIMEUNIT loopendtype
);
JavaScript Syntax
Sound.setLoopPoints(
loopstart,
loopstarttype,
loopend,
loopendtype
);
Parameters
- loopstart
- The loop start point. This point in time is played, so it is inclusive.
- loopstarttype
- The time format used for the loop start point. See FMOD_TIMEUNIT.
- loopend
- The loop end point. This point in time is played, so it is inclusive.
- loopendtype
- The time format used for the loop end point. 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
If a sound was 44100 samples long and you wanted to loop the whole sound, loopstart would be 0, and loopend would be 44099, not 44100. You wouldn't use milliseconds in this case because they are not sample accurate.
If loop end is smaller or equal to loop start, it will result in an error.
If loop start or loop end is larger than the length of the sound, it will result in an error.
Issues with streamed audio. (Sounds created with with System::createStream or FMOD_CREATESTREAM).
When changing the loop points, sounds created with System::createStream or FMOD_CREATESTREAM may already have been pre-buffered and executed their loop logic ahead of time, before this call was even made.
This is dependant on the size of the sound versus the size of the stream decode buffer. See FMOD_CREATESOUNDEXINFO.
If this happens, you may need to reflush the stream buffer. To do this, you can call Channel::setPosition which forces a reflush of the stream buffer.
Note this will usually only happen if you have sounds or looppoints that are smaller than the stream decode buffer size. Otherwise you will not normally encounter any problems.
See Also
- FMOD_TIMEUNIT
- FMOD_MODE
- Sound::getLoopPoints
- Sound::setLoopCount
- System::createStream
- System::setStreamBufferSize
- Channel::setPosition
- FMOD_CREATESOUNDEXINFO
Version 1.10.03 Built on Feb 1, 2018