0

I have a couple of questions as I am trying to integrate FMOD Studio into one of my projects.

Although I have gotten the project playing audio files there are some things left out of the example code provided in the documentation regarded intended use. As I am new to FMOD I find these concepts in the API somewhat elusive to grasp.

Does anyone know if there are any form of guidelines as to what best practices are when using the API.

Where can I find more info about the intended use of FMOD::EventInstances and related interfaces/classes for playing sound. Basically what is my responsibility when using a resource and what does FMOD take care of in terms of memory management etc.

How are you supposed to keep track of the FMOD::ID / GUID per event type. Do I need to manually make an asset list for each event with corresponding GUID and define them for my team? Is the a better dynamic way of doing this? (std::map or similar functionality comes to mind).

1 Answers1

0

You should release() any EventInstances when you are finished with them. If your sound event is a oneshot you can release it instantly after you start playing it, and it will automatically release after the sound completes playing. eg:

Studio::EventInstance* instance;
if (FMOD_ErrorCheck(_eventDescription->createInstance(&instance)))
{
    FMOD_ErrorCheck(instance->start());
    FMOD_ErrorCheck(instance->release());
}

If you want to keep a handle to a sound event so that you can keep playing it then you should probably just keep a handle to the EventDescription, and create new EventInstances each time you wish to play it.

If you don't do this, and you keep the EventInstance, then starting the sound will clip the sound and restart it every time you try to play it.

If you don't want to maintain a list of FMOD Guids then you can load the Master Bank.strings.bank file (or whatever your .strings.bank file is called) generated by FMOD Studio. You can then lookup a FMOD:ID from a string like this:

Studio::ID AudioManager::getEntityId(std::string path)
{
    Studio::ID id = {0};
    FMOD_ErrorCheck(_studioSystem->lookupID(path.c_str(), &id));
    return id;
}

(assumes that _studioSystem is your FMOD::Studio::System* pointer of course)

Doing it this way your team will never need to think about event IDs, just the event path strings. You can get the path of a particular event by right clicking on it in FMOD Studio and selecting Copy Path.

Buzzrick
  • 823
  • 9
  • 21