0
0

Hi!
I have a little problem.
I have a sound with 2 loops and i can easily switch to the second loop, but when i change to the first loop the sounds stops(i thought it was because the end point is behind the current position).
To avoid this problem i tried to set the begin of the loop to the beginning of the first loop and the end of the loop point to the end of the current loop. When the current position of the channel is behind the end of the current loop, the end is set to the end of the first loop.
The code to this idea looks like this:

[code:shepqvn7]//index is the new loop that begins with 0 ms and ends with 1000 ms
//curLoop is the current playing loop that begins with 1000 ms and ends with 2000 ms;
// lps[] is map with a with all loaded LoopPoints

if(index<=curLoop)
{
int pos=0;
sound->setLoopPoints(lps[index].begin,FMOD_TIMEUNIT_MS,lps[curLoop].end,FMOD_TIMEUNIT_MS);
do
{
unsigned int tmp;
channel->getPosition(&tmp,FMOD_TIMEUNIT_MS);
pos=tmp;
} while(pos>=lps[index].end)

unsigned int tmp;
channel-&gt;getPosition(&amp;tmp,FMOD_TIMEUNIT_MS);
pos=tmp;

}

sound->setLoopPoints(lps[index].begin,FMOD_TIMEUNIT_MS,lps[index].end,FMOD_TIMEUNIT_MS);

curLoop=index;[/code:shepqvn7]

Unfortunately it didn’t work and the sound stops when I change to the first loop :(.
Has someone an idea how to solve this problem?

  • You must to post comments
0
0

you’d probably be better off calling setposition on the sound to put it at the start of the new loop then call setloop points. What you’re doing is pretty odd so you will get odd behaviour.

  • You must to post comments
0
0

:(
I wanted to loop between several points in a song depending on the events in a game, but i didn’t know that something like that would be so odd.
Anyway, I’ll have to think of another way to get such an effect.
thx for the help

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.