0
0

First of all, thanks for the excellent library for free for non-commercial use.

I have a odd problem in playing a part of music file – that is

system->createSound(name.c_str(), FMOD_SOFTWARE, 0, &sound);
sound->setLoopPoints(begin, FMOD_TIMEUNIT_MS, end, FMOD_TIMEUNIT_MS);
sound->setLoopCount(2);
system->playSound(FMOD_CHANNEL_FREE, sound, true, &channel);
channel->setPosition(begin, FMOD_TIMEUNIT_MS);
result = channel->setPaused(false);

The above code plays the specified section correctly two times, but the problem now happens – it plays again from the "begin" point for the end of ile.

What I want to to is to stop the playing after repeating the play specified number of times. It seems that the loop count doesnt work?

So the exact question is how to play a section of a file for a given number of times and stop the playing afterwards?

Thanks in advance for all replies

  • You must to post comments
0
0

The loop count behaves exactly as it is supposed to. It loops twice and then plays to the end. Why do you have the end of a file if you dont want to play it? The alternative method is to manually stop the channel yourself with polling, or use Channel::setDelay to tell the sound to stop at an exact point after a certain number of samples have played.

  • You must to post comments
0
0

Thanks for the reply.

What I want to do with looping is to randomly select a part of song and looping the part for a specified times. The application is to teach young kids to learn the song with game. That is why we need to loop a specific part of a song in the application. We tried to divide the song into many short songs, but it’s a labor work, so, I think if we use the looping function, we could easily implement the feature.
According to your suggestion, I’m going to try to poll the current position with callback function. But the manual says FMOD could do the callback synchronizing with the "update" function. So, detecting the exact position of loop is not possible.

Anyway, FMOD is an excellent library, and I’m enjoying the powerful features of the FMOD thesedays. Thanks for the FMOD team for the great contribution !!!!

  • You must to post comments
0
0

You missed the setdelay function which will stop a sound after an exact number of output samples, and will not be governed by the update function. In fact using this technique you wouldnt even use the setLoopCount function, it wouldnt be needed. (just calculate how long you want to sound to play including x number of loops then tell it to stop at that point)

  • You must to post comments
0
0

Thanks for the additional information:

I’ve coded like the following according to you suggestion using setDelay

system->createSound(name.c_str(), FMOD_SOFTWARE, 0, &sound);
system->playSound(FMOD_CHANNEL_FREE, sound, true, &channel);
channel->setPosition(begin, FMOD_TIMEUNIT_MS);
channel->setDelay(FMOD_DELAYTYPE_END_MS, end-begin, 0);
result = channel->setPaused(false);

Unfortunately, still don’t work? Cannot tell what the problem is.

  • You must to post comments
0
0

you have to use the dspclock end enum, not end_ms, look at the docs all that does is add silence to the end of the sound.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.