Loading delay exceeded warning when using Programmer Instrument and Audio Table

Hi!

I’m currently working on a project with several thousand voice lines, so the logical conclusion was to use the Programmer Instrument in combination with the Audio Table. Using the Unity Integration documentation I was able to get it to work and everything seems to be in order, but I keep getting the following error message:

[FMOD] SoundSourceInstrumentInstance::startChannelIfReady : Loading delay exceeded, sound may play at incorrect time

So far I’ve tried the following:

  • Preload the bank that contains the event containing the programmer instrument
  • Preload the bank containing the audiotable
  • Use the createStream function instead of the createSound function

None of these things have had any impact. I’m hoping someone can give me the golden tip that I need.

NB: I don’t actually hear any significant delay, but before I implement this on our development branch I would like to make sure that nothing is wrong and/or avoid (superfluous) warnings.

Thanks!
Ruben

The “Loading delay exceeded” message indicates that the sampledata was not finished loading when you tried to start the event instance.

Loading a bank just loads the metadata for the events in that bank, not the sampledata. To load the sampledata of an event prior to playing an instance of the event, call Studio::EventDescription::loadSampleData. It is best to do this a short period of time before you create an instance of the event, so that the sampledata has time to load.

It is also possible to load all the sampledata for an entire bank by calling Studio::Bank::loadSampleData.

If you call Studio::EventDescription::createInstance without having loaded the sampledata ahead of time, FMOD will automatically load the required sampledata required by that event instance.

In all cases, if you do not allow enough time for the sampledata to load before starting an instance of an event that uses that sampledata, you will see the “Loading delay exceeded” message you described.

You can read more about sampledata loading in the Sample Data Loading section of the Studio API Guide chapter of the FMOD API User Manual.

Hi Joseph, thanks for your answer!

I’ve tried loading the event containing the programmer event using loadSampleData, but that did not amount to anything. I am assuming that is because the event itself does not contain any sampledata until I put it there during the callback.

Loading the bank containing the Audio Table and passing true for the loadSamples parameter did not seem to do the trick either. For as far as I can see, only sampledata that has been implemented in an event can be preloaded, so it would make sense that the separate files in the Audio Table would not be preloaded in that case.

Is there a way to preload sampledata of a file referenced in an Audio Table?

Oh! You’re using programmer instruments. Yes, loading the event or bank’s sampledata won’t help in that case, as the sampledata isn’t specifically associated with any event.

The only way to preload the sampledata of assets in a bank’s audio table is to create them as sounds via the Core API. You can call System::createSound to load an individual asset.

1 Like

Ah yes perfect, that seems to make it work!

Just to make sure I am using this correctly, I’m currently following these steps:

  • load the asset by calling createSound
  • wait for the getOpenState to return READY
  • use the programmer instrument callback to pass the sound.handle IntPtr value and subindex

// Retrieve the user data
instance.getUserData(out soundInfoPtr);

// Get the sound info object
soundInfoHandle = GCHandle.FromIntPtr(soundInfoPtr);
soundInfo = soundInfoHandle.Target as SoundInfo;

var parameter = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure(parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));

parameter.sound = soundInfo.SoundHandle;
parameter.subsoundIndex = soundInfo.SubIndex;
Marshal.StructureToPtr(parameter, parameterPtr, false);

1 Like

That looks reasonable, assuming you’re storing the sound object created by createSound in the event instance’s user data - and if it’s working, you must be.

1 Like