0
0

Hi,

I’m trying to set a channel to a certain position. However when setPosition fails because the time is to long on a non-looping sound it doesn’t stop the sound. However if it’s a looping sound I simply want it to modulate to the correct position in the sound. With the error condition alone it doesn’t seem to be possible to do this. I looked at channel and I couldn’t find a way to get if it’s looping (getLoopCount seems to be not from the designer) or what the channel length is. How do I get these or solve the issue otherwise?

My code:
bool SetFMODEventSoundPosition(FMOD::Event* pEvent, int timeMilliSeconds)
{
bool bReturnValue(true);
FMOD::ChannelGroup* channelGroup(NULL);
pEvent->getChannelGroup(&channelGroup);
if (channelGroup)
{
int numChannels(0);
channelGroup->getNumChannels(&numChannels);

        for (int i(0); i < numChannels; ++i)
        {
            FMOD::Channel* channel(NULL);
            channelGroup->getChannel(i, &channel);
            if (channel)
            {
                 if (FMOD_ERR_INVALID_POSITION == channel->setPosition(timeMilliSeconds, FMOD_TIMEUNIT_MS))
                 {
                     channel->stop(); //This causes looped sounds to stop which is not what I want.  However without it non-looping sounds never stop
                 }
            }
        }
    }

    return bReturnValue;
}
  • You must to post comments
0
0

Channel::getMode will return a set of flags that will include:

FMOD_LOOP_OFF 0x00000001
FMOD_LOOP_NORMAL 0x00000002
FMOD_LOOP_BIDI 0x00000004

You can use that to determine whether it is looping or not.

  • You must to post comments
0
0

Thanks.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.