Hello everyone,
I have an issue with getting the real length of a programmers sound with FMOD in Unreal Engine.
The blueprint node “GetLength” and the “Sound->getLength()” always return 2000 ms even if the sound is longer than this.
so I searched in to the forum and I found this:
So I decided to do this:
in MyClass.cpp I wrote this:
void MyClass::PlayLineSound()
{
if(FMODAudioComponent)
{
FMODAudioComponent->Stop();
FMODAudioComponent->SetEvent(GetFMODEvent());
FMODAudioComponent->SetProgrammerSoundName(GetProgrammerSoundName());
FMODAudioComponent->StudioInstance->setCallback(&MyClass::MyCallback, FMOD_STUDIO_EVENT_CALLBACK_SOUND_PLAYED);
FMODAudioComponent->Play();
}
}
and then this is the callback:
FMOD_RESULT F_CALLBACK MyClass::MyCallback(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, FMOD_STUDIO_EVENTINSTANCE* event, void* parameters)
{
unsigned int length;
FMOD::Sound* Sound = static_cast<FMOD::Sound*>(parameters);
Sound->getLength(&length, FMOD_TIMEUNIT_MS);
CurrentSoundDuration = static_cast<int32>(length);
return FMOD_OK;
}
but when I print out my “CurrentSoundDuration” I always get 2000 ms, even if the sound is 5 seconds long.
Am I doing something wrong? Can you help me?
Thanks.