Hi, I am new to FMOD and is using latest stable version 4.40.05 on Windows (32 bit)
I createSound using FMOD_SOFTWARE, then playSound using FMOD_CHANNEL_FREE and &channel. As I needed the sound to loop, I did
channel->setMode(FMOD_LOOP_NORMAL), which works fine for unlimited looping. However, in another case I need it to loop a certain number of times. So I tried setLoopCount.
However, channel->setLoopCount(5) will not work. When the sound is playing, the loop count shows 5. After the sound has been played, the loop count instantly reset to 0 (maybe the handle has invalidated and the loop won’t use back the same channel). In any case, it is not looping for me. Any ideas?
- CyberMew asked 4 years ago
Hi CyberMew, Welcome to the FMOD Forum!
Make sure you’re checking the FMOD_RESULT returned from every call to the FMOD API, that makes it easy to catch invalid handle errors. Generally the easiest way to make looping sounds is to pass that FMOD_MODE flag for looping stright into the createSound call, that will make the FMOD Sound object know that it should always loop and you don’t have to worry about altering state on channels which are already playing. You can also set the loop count directly on the Sound instead of the Channel if you want a fixed loop count. There is a difference between the way getLoopCount works for Channels and Sounds, each time the channel loops the loop count variable is decremented, whereas it remains constant for the sound object. So in the context of the channel it can be thought of as how many [i:13ogedya]more[/i:13ogedya] loops to play rather than how many loops will play total.
Hi, thanks for the reply.
I have checked and all is returning FMOD_OK to me except the channel for setLoopCount(). So internally it doesn’t seems to reuse the channel and don’t make sense to print getLoopCount with the original channel. As I need it to be more flexible, i.e. playSound xxx times, instead of each sound object having a fix count, is there any other reason you can think of as to why channel->setLoopCount() won’t work? If it matters, that channel belongs to a channelgroup as well.
Any help is greatly appreciated.
Please login first to submit.