I would like to be able to stitch together sections of several sound files at runtime, with ideally no pausing.

I had imagined that the way to do this would be firstly create my fragments like this:

[code:d1fvd7k0]//Create two sounds, each with their own loop points
FMOD::Sound* subsound[2];
result = system->createSound("test.mp3", FMOD_CREATESTREAM|FMOD_LOOP_NORMAL|FMOD_2D|FMOD_SOFTWARE, 0, &subsound[0]);
result = subsound[0]->setLoopPoints(30000, FMOD_TIMEUNIT_MS, 35000,FMOD_TIMEUNIT_MS);
result = subsound[0]->setLoopCount(1);

result = system->createSound("test.mp3", FMOD_CREATESTREAM|FMOD_LOOP_NORMAL|FMOD_2D|FMOD_SOFTWARE, 0, &subsound[1]);
result = subsound[1]->setLoopPoints(60000, FMOD_TIMEUNIT_MS, 65000,FMOD_TIMEUNIT_MS);
result = subsound[1]->setLoopCount(1);[/code:d1fvd7k0]

I would then create another sound, add these sounds as its subsounds, and use setSubSoundSentence to have it stitch them together.

[code:d1fvd7k0]//Create a sound that uses these two sounds in a sentence
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.defaultfrequency = 44100;
exinfo.numsubsounds = 2;
exinfo.numchannels = 2;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;

FMOD::Sound* sound;

result = sound->setSubSound(0, subsound[0]);
result = sound->setSubSound(1, subsound[1]);

int soundlist[2] = {0,1};
result = sound->setSubSoundSentence(soundlist, 2);


Then play.

[code:d1fvd7k0] //Play sound
FMOD::Channel* channel = 0;
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);[/code:d1fvd7k0]

The problem, is that the ‘loopstart’ position in the setLoopPoints function is ignored – each sound always plays from the start.

I think that I may be using the setLoopPoints function inappropriately – I’d appreciate any comments that could point me in the right direction. Thankyou!

  • You must to post comments

Thanks Brett, I was afraid that this was the case. I wonder if you could give me any indication as to how I might achieve this effect using some other strategy? Possibly using callbacks?

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.