For our project we need localization and we use programmer sounds for that. We also want to be able to play multiple programmer instruments in the same event. We tried to learn from the example in the API but we did not get the callback to work.
We use a class that inherits from the FMODAudioComponent. In that class we tried to set up a progammerSound callback.
In the .h file of that SoundComponent class we added following code.
// Programmer sound
struct ProgrammerSoundContext
{
FMOD::System* coreSystem;
FMOD::Studio::System* system;
const char* dialogueString;
};
#define CHECK_RESULT(op) \
{ \
FMOD_RESULT res = (op); \
if (res != FMOD_OK) \
{ \
return res; \
} \
}
FMOD_RESULT F_CALLBACK programmerSoundCallback(FMOD_STUDIO_EVENT_CALLBACK_TYPE type, FMOD_STUDIO_EVENTINSTANCE* event, void* parameters);
// Programmer sound end
In the cpp constuctor we added
FMOD::Studio::System* System = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext::Max);
FMOD::Studio::EventDescription* eventDescription = NULL;
System->getEvent("event:/Character/Dialogue", &eventDescription);
FMOD::Studio::EventInstance* eventInstance = NULL;
eventDescription->createInstance(&eventInstance);
eventInstance->setUserData(&programmerSoundContext);
eventInstance->setCallback(programmerSoundCallback, FMOD_STUDIO_EVENT_CALLBACK_CREATE_PROGRAMMER_SOUND | FMOD_STUDIO_EVENT_CALLBACK_DESTROY_PROGRAMMER_SOUND);
bAutoActivate = false;
In our dialogue class we have a play dialogue function which has this code in the end
Component->SetEvent(Event);
Component->SetProgrammerSoundName(Dialogue);
FMOD_RESULT Result = Component->StudioInstance->setCallback(programmerSoundCallback);
if (Result != FMOD_OK)
{
UE_LOG(LogTemp, Error, TEXT("Dialog::setcallback failed"));
}
Component->Play();
CanPlayQueuedDialogues = true;
OnDialogueStart.Broadcast(Dialogue, Component);
We get error 30 “Invalid handle” for the setcallback function. Also studio instance seems to be Null. There is probably something fundamental we got wrong here.
If we can get the callback to work then we still haven’t found any information about how to play multiple programmer sounds in the same event. So some more information on that would also be nice.
We are using Unreal 5.1 github source code version with FMOD studio 2.0.2.06