FMOD 2.0 and the new Unity integration codes

#1

Hey folks,

I really love the new FMOD 2.0 features and wanted to put them straight to use. Unfortunately the API changed along with the 2.0 update and therefore some of the old integration codes won’t worked anymore.

I’ve been reading the documentation and reviewed the new code examples in the “Learn” section. But as I’m not a programmer, I can’t really make sense out of it. So I was wondering if anybody can tell me how I need to replace my old codes to make things work again.

What are the new corresponding codes to the following old ones?

FMOD.Studio.ParameterInstance XXXParameter;
XXX.getParameter("PARAMETERNAME", out XXXParameter);
XXXParameter.setValue(1f);
XXX.setParameterValue("PARAMETERNAME", 0f);

The documentation always talks about “IDs” and “Descriptions”. It seems like working with these should be better in case of performance. But how do I set an ID? How can I recall and change the value of a parameter linked to an ID? What’s the difference between an ID and a Description?

Working with names was straight forward to me, but this new ID and Description approach kinda confuses me.

0 Likes

Overview of obsolete API stuff when upgraded to 2.0?
#2

After some more research I came across this:

XXX.setParameterValue("PARAMETERNAME", 1f);

is now

XXX.setParameterByName("PARAMETERNAME", 1f);

Parameter instances have been remove completely and therefore the parameter value can only be read out and stored via description. Unfortunately this more than doubles the amount of needed code !!

FMOD.Studio.ParameterInstance XXXParameter;
XXX.getParameter("PARAMETERNAME", out XXXParameter);
XXXParameter.setValue(1f);

is now

FMOD.Studio.EventDescription XXXDescription;
FMOD.Studio.PARAMETER_DESCRIPTION ParameterDescription;
FMOD.Studio.PARAMETER_ID ParameterId;
XXXDescription = FMODUnity.RuntimeManager.GetEventDescription(XXXEvent);
XXXDescription.getParameterDescriptionByName("PARAMETERNAME", out ParameterDescription);
ParameterId = ParameterDescription.id;
XXX.setParameterByID(ParameterId, 1f);

Wold be nice if anyone can confirm this.

0 Likes

#3

We introduced a new parameter API in 2.0, a summary of it can be found here:
https://www.fmod.com/resources/documentation-api?version=2.0&page=welcome-whats-new-200.html#new-parameter-api

ID’s are more performant when you need to get or set a parameter multiple times.

If you are just setting a parameter once or twice then it may not be worth the work to store the description and ID, in this case you can use EventInstance::get/setParameterByName.

0 Likes

#4

How much more performant is storing a description / ID compared to setting the parameter by name, so I can get a feeling for what situations it would be worth the extra work? Is it possible to measure this (like 20% faster or something like that)?

0 Likes

#5

We don’t have any numbers on this, but it comes down to a series of integer comparisons vs a series of string comparisons. In general integer comparisons will always be faster than string.

Example: If you want to compare 1073741822 with 1073741823.

  • String comparison: You have to compare each of the digits one by one. This is 10 comparisons, since the integers only differ by the last digit.
  • Integer comparison: You can do this in one comparison, saving 9 comparisons as compared to the String comparison.

This is a bit simplified, naturally, but hopefully gets the point across.

0 Likes

#6

Thank you very much, that helps.

0 Likes