Studio API [C++] General Questions (New to FMOD)

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. The documentation file only specifies what functions are available and not it’s intended use as a whole.

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).

If anyone has any form of resource about the API and it’s intended use I would appreciate a little nudge in the right direction :smiley:

Also is there any way of having FMOD triggering callbacks that I can pass along to my engine. (Like a tag defined in the event that does not trigger a programmer sound but instead sends a predefined value)

I have a related question, so I am hijacking this thread.

I am able to use the API to load resources from bank files provided with the example media. I use the user-friendly name in lookupID, as you suggested, just like the example code shows. I can play the sounds in my own application with no problems.

I have a problem when I try to load a simple bank file I created myself in Studio. I got the user-friendly names from project/Build/GUIDs.txt, which were very similar to names the example code and media. lookupID always fails, returning ERR_EVENT_NOTFOUND. I suspect the problem is I am loading the wrong .bank file from my Studio project folder. I found several bank files. The ‘strings’ file you mention is located at project/Build/Desktop, and another .bank file is in that same folder, so I load both.

Am I loading the wrong file or do I need to do something to my Studio project? I tried the File->Build menu, but it did not help.

Thanks,
John

[edit] I added my Studio project folder. [/edit]

The documentation does say that ERR_EVENT_NOTFOUND is returned if the master string bank is not loaded.
if all your audio files fail to play, did you check that the string bank is actually loaded?

Yes, I checked they are loaded.

I load these 2 files:
1- project/Build/Desktop/Master Bank.bank
2- project/Build/Desktop/Master Bank.strings.bank

Studio::System::loadBankFile returns FMOD_OK when I load each of these files.

The examples load the 2 banks above, but also .bank files called Weapons, UI_Menu, and Surround_Ambience.

Do I need other .bank files? How do I create any .bank files other than the ‘master’ .bank files?

Thanks!
John

I found a solution.

1- I had to create a new ‘bank’ on the Banks tab, next to the Events tab.
2- On the Events tab, I had to right-click on an event and ‘Assign to Bank’.
3- On the Banks tab, I had to select all banks (Control+A) before File->Build
4- In my folder, ‘project/Build/Desktop’, a new .bank file exists. My code loads this new file, the Master, and the Master.strings bank files.

Thank you, that cleared up quite a bit :smiley:

We’re always working on improving the documentation and I agree that currently, the overview of best practices is still somewhat lacking.

The FMOD types are returned in handles that either appear as classes in C++ or opaque pointers to structures in C. Any class with a release() is intended to be created, used, and then released. The examples should show several working examples of that. For instance the simple_example creates one-shots and calls EventInstance::release() on them when finished. At the end of execution banks are unloaded with Bank::unload() - which also will destroy any instances using that bank. Ultimately Studio::System::release() shuts down FMOD and will unload any banks and destroy any remaining instances left over.

At no time should user code ever try to call C++ “delete” on a FMOD class directly. If you try that, you’ll see that it just won’t work.

In terms of looking up instances via GUID, the typical way is one of the following:
1.) Load the master strings bank and then call System::lookupID to turn a user-friendly name into a GUID
2.) Export GUIDS.txt from within Studio. That is a text file with a list of GUIDs and their event name. That text file can be used as part of a custom build process to translate the events to GUIDs in some way before using them with the runtime API.

Unless you have a specific workflow in mind I’d recommend using (1), and looking them up by name where needed.

We don’t have any way of triggering callbacks at specified points on the timeline in the current build. The only workaround in the meantime would be to add user properties per event, and at runtime query the event’s timeline to match them up. This isn’t as user friendly as putting down a hypothetical game callback box, but it would allow the designer to specify times at the timeline when things happen. Since the user properties are arbitrary strings, they could be “encoded” with a timeline position, as well as any other string data that the game can parse and act upon.