# Problem with playing Sounds Sequentially

**URL:** <https://qa.fmod.com/t/problem-with-playing-sounds-sequentially/15141>\
**Category:** FMOD Engine\
**Created:** [October 16, 2019, 7:24pm UTC](https://qa.fmod.com/t/problem-with-playing-sounds-sequentially/15141 "2019-10-16T19:24:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KayDemonLP](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/kaydemonlp/32/1688_2.png) [@KayDemonLP](https://qa.fmod.com/u/KayDemonLP)\
**Post date:** [October 16, 2019, 7:24pm UTC](https://qa.fmod.com/t/problem-with-playing-sounds-sequentially/15141/1 "2019-10-16T19:24:47Z")

</div>

Was working with FMOD Ex before which had setSubSoundSentence to make 2 sounds play one after another.  
After i switched to FMOD Studio i saw that this function was gone.  
Reading more about it i saw that it got removed due to setDelay being more acurate, however i had problems with finding documentation on how to use it properly so i used the granual\_synth example for reference.  
However the second sound starts playing way too quickly ( the first song is 30 seconds long and the second one already starts within the first 2 seconds ).  
The only modifying to the queue\_next\_sound i did was making the sound and channel be set in the function ( instead of it being the 2 fixated ones )

> Channel \*queue\_next\_sound(int outputrate, Channel \*playingchannel, const char\* soundname, Sound \*pQueuedSound)

Called like this

> void CFMODManager::PlayLoopingMusic(const char\* pLoopingMusic, const char\* pIntroMusic, bool fadeIn)  
> {  
> if (pIntroMusic)  
> {  
> Sound \*pIntroSound = NULL;  
> Sound \*pLoopingSound = NULL;
> 
> ```
> int outputrate = 0;
> result = pSystem->getSoftwareFormat(&outputrate, 0, 0);
> pChannel[0] = queue_next_sound(outputrate, NULL, GetFullPathToSound(pIntroMusic), >pIntroSound);
> pChannel[1] = queue_next_sound(outputrate, pChannel[0], >GetFullPathToSound(pLoopingMusic), pLoopingSound);
> 
> ```
> 
> }  
> …  
> }

---

<div class="post-metadata">

**Author:** ![chrisjdarcy](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/chrisjdarcy/32/172_2.png) [@chrisjdarcy](https://qa.fmod.com/u/chrisjdarcy)\
**Post date:** [October 17, 2019, 10:34am UTC](https://qa.fmod.com/t/problem-with-playing-sounds-sequentially/15141/2 "2019-10-17T10:34:11Z")

</div>

Sequential playback is available in the options of the Multi Instrument:

[![](https://i.gyazo.com/e7807d1d6a71ed90d46b8a4fb2a70d40.png) ](https://i.gyazo.com/e7807d1d6a71ed90d46b8a4fb2a70d40.png)

---

<div class="post-metadata">

**Author:** ![KayDemonLP](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/kaydemonlp/32/1688_2.png) [@KayDemonLP](https://qa.fmod.com/u/KayDemonLP)\
**Post date:** [October 18, 2019, 10:47pm UTC](https://qa.fmod.com/t/problem-with-playing-sounds-sequentially/15141/3 "2019-10-18T22:47:04Z")

</div>

Im not sure i follow.  
Isn’t that the FMOD Studio Tool and not the API?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [October 22, 2019, 11:50pm UTC](https://qa.fmod.com/t/problem-with-playing-sounds-sequentially/15141/4 "2019-10-22T23:50:33Z")

</div>

Does the granual\_synth example work as expected?  
Are you doing anything very different to the example in queue\_next\_sound?

---

<div class="post-metadata">

**Author:** ![KayDemonLP](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/kaydemonlp/32/1688_2.png) [@KayDemonLP](https://qa.fmod.com/u/KayDemonLP)\
**Post date:** [October 24, 2019, 12:05pm UTC](https://qa.fmod.com/t/problem-with-playing-sounds-sequentially/15141/5 "2019-10-24T12:05:37Z")

</div>

I wasn’t able to properly understand granual\_synth however after some testing i managed to get a version based on gapeless\_playback working

> void CFMODManager::PlayLoopingMusic(const char\* pLoopingMusic, const char\* pIntroMusic)  
> {  
> if (pIntroMusic)  
> {  
> Sound \*pIntroSound = NULL;  
> Sound \*pLoopingSound = NULL;  
> result = pSystem-\>createChannelGroup(“Parent”, &pChannelGroup);  
> int outputrate = 0;  
> result = pSystem-\>getSoftwareFormat(&outputrate, 0, 0);  
> unsigned int dsp\_block\_len = 0;  
> result = pSystem-\>getDSPBufferSize(&dsp\_block\_len, 0);  
> unsigned long long clock\_start = 0;
> 
> ```
> result = pSystem->createStream(GetFullPathToSound(pIntroMusic), FMOD_CREATESTREAM, 0, &pIntroSound);
> pSystem->playSound(pIntroSound, pChannelGroup, true, &pChannel);
> 
> result = pChannel->getDSPClock(0, &clock_start);
> 
> clock_start += (dsp_block_len * 2);
> 
> result = pChannel->setDelay(clock_start, 0, false);
> result = pChannel->setPaused(false);
> 
> result = pLoopingSound->setLoopPoints(0, FMOD_TIMEUNIT_PCM, GetSoundLenghtPCM(pLoopingSound), FMOD_TIMEUNIT_PCM);
> result = pSystem->createStream(GetFullPathToSound(pLoopingMusic), FMOD_LOOP_NORMAL | FMOD_CREATESTREAM , 0, &pLoopingSound);
> pSystem->playSound(pLoopingSound, pChannelGroup, true, &pChannel);
> 
> float freq;
> unsigned int slen;
> 
> result = pIntroSound->getLength(&slen, FMOD_TIMEUNIT_PCM);
> result = pIntroSound->getDefaults(&freq, 0);
> 
> slen = (unsigned int)((float)slen / freq * outputrate);
> 
> clock_start += slen;
> 
> result = pChannel->setDelay(clock_start, 0, false);
> result = pChannel->setPaused(false);
> 
> ```
> 
> }  
> …  
> }
