[Resolved] channel desynchronised

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

        FMOD::Studio::System system;
        FMOD_RESULT result = FMOD::Studio::System::create(&system);
        void *extraDriverData = 0;
        result = system.initialize(32, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData);
        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();

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:

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



_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.

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

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