Problem with playing Sounds Sequentially

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);

}

}

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

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

Does the granual_synth example work as expected?
Are you doing anything very different to the example in queue_next_sound?

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);

}

}

1 Like