0
0

Im trying to loop a sound using the "FMOD_RESULT F_API setLoopCount (int loopcount);" function in fmod.hpp but i don’t get it to work…

It looks like this:
[code:369julsg]void SoundSystem::SetLoopCount(const int aSoundIndex, const int aLoopCount)
{
mySoundObjects.at(aSoundIndex).mySound->setLoopCount(aLoopCount);
}[/code:369julsg]
and then using:[code:369julsg]
bool SoundSystem::PlaySound(const int aSoundId)
{
if(aSoundId < mySoundObjects.size() && aSoundId >= 0)
{
myResult = mySystem->playSound(FMOD_CHANNEL_REUSE, mySoundObjects.at(aSoundId).mySound, false, &mySoundObjects.at(aSoundId).myChannel);
return true;
}
return false;
}[/code:369julsg]
to play the sound but it only play it once.

Can someone tell me why?

  • You must to post comments
0
0

Funny, i’ve just been looking at looping as well. I have to say I a real fmod newbie, but I in the following example, calling sound->setLoopCount(0); did prevent the sound from looping.

[code:10wwkbkk]
FMOD_RESULT result;
FMOD::System *system;

result = FMOD::System_Create(&amp;system);      // Create the main system object.
if (result != FMOD_OK)
{
    printf(&quot;FMOD error! (%d) %s\n&quot;, result, FMOD_ErrorString(result));
    exit(-1);
}

result = system-&gt;init(100, FMOD_INIT_NORMAL, 0); // Initialize FMOD.
if (result != FMOD_OK)
{
    printf(&quot;FMOD error! (%d) %s\n&quot;, result, FMOD_ErrorString(result));
    exit(-1);
}

char buffer[200] = {0};
[[NSString stringWithFormat:@&quot;%@/drumloop.wav&quot;, [[NSBundle mainBundle] resourcePath]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];

FMOD::Sound *sound;
result = system-&gt;createSound(buffer, FMOD_DEFAULT, 0, &amp;sound);       // FMOD_DEFAULT uses the defaults.  These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE.
ERRCHECK(result);
sound-&gt;setLoopCount(0); // prevent the sound from looping

FMOD::Channel *channel;
result = system-&gt;playSound(FMOD_CHANNEL_FREE, sound, false, &amp;channel);
ERRCHECK(result);

[/code:10wwkbkk]

Maybe the fmod ex documentation (fmod.chm file) can help you? Have you tried looking for the FMOD_LOOP_OFF, FMOD_LOOP_NORMAL, FMOD_LOOP_BIDI constants?

Sorry, this is no definite answer to your problem, but have just started learning myself…

  • You must to post comments
0
0

Your tips helped me find the solution!

I’m a beginner also (surprise).

Thank you :)

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.