FMOD Engine User Manual 2.03
The Studio API is designed to be intuitive and flexible. This chapter contains an introduction to using it, and explains the key factors involved in using it effectively.
Before anything else can be done with the Studio API, it is necessary to initialize the studio system.
The Studio API can load FMOD Studio banks and can play events created by sound designers in FMOD Studio. When using the Studio API, you can create a studio system and then call Studio::System::initialize. That function also initializes the in-built core system as well. Here is a simple example:
FMOD_RESULT result;
FMOD::Studio::System* system = NULL;
result = FMOD::Studio::System::create(&system); // Create the Studio System object.
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
// Initialize the Studio system, which also initializes the Core system
result = system->initialize(512, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, 0);
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
The FMOD Engine can be customized with advanced settings by calling Studio::System::setAdvancedSettings before initialization. For a description of the typical settings for effective virtual voices, see the Virtual Voice System section of the Managing Resources in the Core API chapter.
The FMOD Engine should be ticked once per game update. To tick the FMOD Engine while using the Studio API, call Studio::System::update. Internally, this also updates the Core API system.
If the Studio API is running in asynchronous mode (the default, unless FMOD_STUDIO_INIT_SYNCHRONOUS_UPDATE has been specified), then Studio::System::update will be extremely quick, as it is merely swapping a buffer for the asynchronous execution of that frame's commands.
To shut down the Studio API, call Studio::System::release.
In the FMOD examples, the error codes are checked with a macro that calls into a handling function if an unexpected error occurs. That is the recommended way of calling Studio API functions. There is also a callback that can be received whenever a public FMOD function has an error. See FMOD_SYSTEM_CALLBACK for more information.
The output hardware, the FMOD Engine's resource usage, and other types of configuration options can be set if you desire behavior differing from the default. These are generally called before System::init. For examples of these, see Studio::System::getCoreSystem, System::setAdvancedSettings, Studio::System::setAdvancedSettings.