# \[Resolved\] channel desynchronised

**URL:** <https://qa.fmod.com/t/resolved-channel-desynchronised/11048>\
**Category:** FMOD Studio\
**Created:** [June 25, 2013, 3:19pm UTC](https://qa.fmod.com/t/resolved-channel-desynchronised/11048 "2013-06-25T15:19:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierre](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pierre](https://qa.fmod.com/u/pierre)\
**Post date:** [June 25, 2013, 3:19pm UTC](https://qa.fmod.com/t/resolved-channel-desynchronised/11048/1 "2013-06-25T15:19:19Z")

</div>

Dear all,

Fisrt of all, thanks to the fmod team for the amazing work done with the studio API.

We are running into an issue about sound desynchronised.  
The following trace gets printed :  
-\> FMOD: SoundSourceInstrumentInstance::startChannelIfReady : Loading delay exceeded, sound may play at incorrect time

Does anyone know if there a special flag to increase the allowed loading time or if this issue rings a bell ?

We are running the following code (extracted from the samples):

```auto
        
        FMOD::Studio::System system;
        FMOD_RESULT result = FMOD::Studio::System::create(&system);
        _ERRCHECK(result);
        
        void *extraDriverData = 0;
        result = system.initialize(32, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData);
        _ERRCHECK(result);
        const char* bankPath = _mediaPath([localMusic.bank UTF8String]);
        
        FMOD::Studio::Bank masterBank;
        _ERRCHECK( system.loadBank(bankPath, &masterBank) );
        
        const char* eventGUID = [localMusic.mainEventGUID UTF8String];
 
        FMOD::Studio::ID eventID = {0};
        _ERRCHECK( FMOD::Studio::parseID(eventGUID, &eventID) );
        
        FMOD::Studio::EventDescription eventDescription;
        _ERRCHECK( system.getEvent(&eventID, FMOD_STUDIO_LOAD_BEGIN_NOW, &eventDescription) );
        
        FMOD::Studio::EventInstance eventInstance;
        _ERRCHECK( eventDescription.createInstance(&eventInstance) );
        _ERRCHECK( eventInstance.start() );
        
        result = system.update();
```

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://qa.fmod.com/u/Guest)\
**Post date:** [June 26, 2013, 12:40am UTC](https://qa.fmod.com/t/resolved-channel-desynchronised/11048/2 "2013-06-26T00:40:52Z")

</div>

We do plan to make the loading time configurable, but unfortunately this is not implemented yet. However, you can probably solve your problem by waiting for the samples to load before you start the event instance. Samples start loading when you first create an instance of an event, so you can wait for them to load with code like the following:

```auto
FMOD::Studio::EventInstance eventInstance;
_ERRCHECK( eventDescription.createInstance(&eventInstance) );

FMOD_STUDIO_LOADING_STATE state = FMOD_STUDIO_LOADING_STATE_LOADING;
_ERRCHECK(eventInstance.getLoadingState(&state));

while (state == FMOD_STUDIO_LOADING_STATE_LOADING)
{
    Sleep(1);
    _ERRCHECK(eventInstance.getLoadingState(&state));
}

_ERRCHECK( eventInstance.start() );
```

This is just demonstration code - obviously you don’t want to block the main thread waiting for samples to load. However, you could add your event instances to a list and poll their loading state each frame. We are considering implementing this logic internally, so EventInstance::start() waits for samples to finish loading before actually starting the event.

If you want to load all the samples in a bank, you can use Bank::loadSampleData() and Bank::getSampleLoadingState() in a similar manner.

---

<div class="post-metadata">

**Author:** ![pierre](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pierre](https://qa.fmod.com/u/pierre)\
**Post date:** [June 26, 2013, 4:17pm UTC](https://qa.fmod.com/t/resolved-channel-desynchronised/11048/3 "2013-06-26T16:17:25Z")

</div>

Thanks a lot for the quick feedback, it works like a charm 🙂

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://qa.fmod.com/u/Guest)\
**Post date:** [June 27, 2013, 12:17am UTC](https://qa.fmod.com/t/resolved-channel-desynchronised/11048/4 "2013-06-27T00:17:45Z")

</div>

I’m glad to hear it! I’ll mark this topic as resolved.
