Sometimes,the function returns 0,but obviously the event timeline length is not 0.
ERRCHECK( explosionDescription->loadSampleData() );
int dd = -1;
ss is false and
s is loaded,but
dd is still 0.
And below is my fmod init code:
void *extraDriverData = NULL;
FMOD::Studio::System* system = NULL;
ERRCHECK( FMOD::Studio::System::create(&system) );
// The example Studio project is authored for 5.1 sound, so set up the system output mode to match
FMOD::System* lowLevelSystem = NULL;
ERRCHECK( system->getLowLevelSystem(&lowLevelSystem) );
ERRCHECK( lowLevelSystem->setSoftwareFormat(0, FMOD_SPEAKERMODE_5POINT1, 0) );
ERRCHECK( system->initialize(32, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData) );
Have you checked the return value from Studio::EventDescription::getLength? Perhaps there was an error.
I checked it,but no error happened.I have posted my code above.
In your code, is explosionDescription referring to the “Single Explosion” event in the Studio examples project? If so, then its timeline is empty, and thus Studio::EventDescription::getLength should return 0.
Note that Studio::EventDescription::getLength returning 0 doesn’t necessarily mean that the event won’t play anything. It just means there are no sounds on the timeline. In the explosion example, it has sounds on the “Size” parameter and these will play according to the parameter’s value.
So Studio::EventDescription::getLength is just an informational function, telling you how long the timeline will tick before it runs out. The actual length of time that an event plays can vary according to the parameter values, transitions, loops, sustain points, pitch, AHDSR, etc.
Is there a way to get the actual length of time from the Size parameter?
I also have this problem, we put the sound source to an extra parameter, but we must get the actual length of the time.
Unfortunately there are too many factors to take into account to determine the length of an event when it comes to instruments on parameters. We can only provide the length of the timeline.