Hi, sorry for the duplicate in the topic, but I didn’t find any solution that works so far, and a little bit of help would be very much appreciated. I made the following 5 tries.
I tried to use call-backs, like the code below, but they never get called:
Sorry for the long post, for so much code (in case I can also give you the code to copy and paste if images are not comfortable) and that it is divided in multiple answers. However, I wanted to make you understand all the attempts I did so far.
The error: 46 - NOT READY from the fact we are loading the sound from an audio table. To solve that we can check the FMOD_OPENSTATE and wait till it is ready:
FMOD_OPENSTATE state = FMOD_OPENSTATE_MAX;
bool starving, diskBusy = false;
unsigned int percent = 0;
FMOD_RESULT result = Sound->getOpenState(&state, &percent, &starving, &diskBusy);
while (state != FMOD_OPENSTATE_READY && result == FMOD_OK)
{
result = Sound->getOpenState(&state, &percent, &starving, &diskBusy);
}
if (result != FMOD_OK)
{
// Log error here
}
Since we are loading the sound from an Audio table, it wont actually be Sound that is the Master.bank. So we will need to retrieve actual sound with FMOD Engine | Core Api Sound - Sound::Getsubsound
FMOD::Sound* subSound1 = nullptr;
result = Sound->getSubSound(0, &subSound1);
unsigned int length = 0;
result = FMOD_Sound_GetLength((FMOD_SOUND*)subSound1, &length, FMOD_TIMEUNIT_MS);
This should return to correct length. You can add some more checks:
As for the rest, everything was super clear, thanks! I was able to make it work by modifying the AudioComponent.cpp, storing the Sound in a variable, and upon request in another function, retrieve the subsound and getting the correct length.
As for the setCallback(), the three times where just an example, I tried one at the time. However, still no luck, it seems that the callback is never actually called.
I will mark your reply as the solution, as it actually solved the problem. In case I will need the callbacks, I will open another forum post.
Thank you so much once again for your kind help Connor, have a wonderful day ahead!