Firelight Technologies FMOD Studio API
Programming Support
Programming with the FMOD Studio plugin
Programmers can interface with FMOD Studio directly. To reference FMOD Studio, the programmer will need to add the following to their .Build.cs file:
- Add "FMODStudio" to PrivateDependencyModuleNames
To add some FMOD Events to a class, do the following:
- Include "FMODEvent.h" at the top of your own class
- Add a UFMODEvent * and mark with the UPROPERTY macro like any other field
To play the event at a location, do the following:
- Include "FMODBlueprintStatics.h" in the file you want to trigger the sound
- Call UFMODBlueprintStatics::PlayEventAtLocation with the following arguments:
- Set WorldContextObject to any UObject in the world, such as the owning actor object
- Set Event to the UFMODEvent stored in the class or passed into your function
- Set Transform to the place in the world you want to play the sound
- Set bAutoPlay to true so that it starts the sound automatically
You can also call UFMODBlueprintStatics::PlayEventAttached to create a new audio component attached to an actor, which will update the location automatically as the actor moves around the world.
Programming with the FMOD Studio C++ API
Programmers can interface with FMOD Studio directly by including "fmod_studio.hpp".
The Studio system can be obtained by GetStudioSystem. The function takes an enum because there may be a separate Studio system for auditioning in-editor and the proper system for play-in-editor. Normally, you will want to obtain the system with EFMODSystemContext.Runtime since that is the real system used in game.
if (IFMODStudioModule::IsAvailable())
{
FMOD::Studio::System* StudioSystem = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext::Runtime);
if (StudioSystem)
{
// Use it here
}
}
You can use a mixture of FMOD Studio wrapper and FMOD Studio API functions. For example:
// Call wrapper helper function to create and start an event instance
FFMODEventInstance InstanceWrapper = UFMODBlueprintStatics::PlayEventAtLocation(ThisActor, MyEvent, FTransform(MyLocation), true);
FMOD::Studio::EventInstance* Instance = InstanceWrapper.Instance;
// Call into FMOD API directly
Instance->setVolume(0.5f);
// The instance handle will be cleaned up automatically when the sound finishes
Further Programming Documentation
For further documentation, see the Programmer Topics section or the API Reference.