Can't change pitch through a snapshot using parameters

Hi,
Trying to do a slowmo effect that also lowers the pitch of all sounds in the SFX Group.

I have a local parameter called Bullet Time Pitch that, when its 1, has the pitch modified by 0 using an automation curve, and -24st at 0.

in my code I’m doing this:

void Awake()
{
BulletTime = FMODUnity.RuntimeManager.CreateInstance("snapshot:/Bullet Time");
}

void StartSlowMo(float TargetTimeScale)
{
BulletTime.setParameterByName("Bullet Time Pitch", targetTimeScale);
}

void StopSlowMo()
{
BulletTime.setParameterByName("Bullet Time Pitch", 1f);
}

but it doesn’t work. if I debug.Log the value of “Bullet Time Pitch” using getParameterByName, it always returns as 0 even when it should be my given value.

if I add a global parameter instead, and do

FMODUnity.RuntimeManager.StudioSystem.setParameterByName("Bullet Time Pitch", 1f);

it does actually set the value of the parameter to my given float, as I can tell through a debug.log print + getParameterByName. however, in game, nothing happens.

Additionally the documentation says it’s supposed to return an error if it can’t find a parameter with the given name, but even if I type in some random nonsense, I don’t get any errors; it just always returns 0 if I try to getParameterByName, which means that I’m not really sure how to debug this.

Any help would be appreciated, thanks.

Figured it out, I had to call eventinstance.start() on the BulletTime instance (i.e. play it, and leave it looping in the background.)

Still not sure why there are no error messages for this sort of thing as it makes missing things quite easy.

Hi,

Thank you for sharing the solution!

Yes, from my understanding, Studio::EventInstance::getParameterByName will still return FMOD_OK in this case because:

  • The parameter technically exists in the event’s definition.
  • FMOD does not treat it as an error if the instance is inactive or the parameter hasn’t been instantiated yet.

Could you please let me know which part of the documentation mentioned that an error should be returned?

From what I can see, the getParameterByName documentation describes how value and finalvalue are returned, but it doesn’t mention specific error codes for invalid or unknown parameter names.

In practice, the function typically returns FMOD_OK and silently returns 0.0f for the value even if the parameter name is invalid or the instance hasn’t been started. I agree this can be confusing at times.

I’ll forward this feedback to the dev team to see if we can clarify the documentation. Thanks again for pointing this out!

it says it here: (in setParameter not getParameter)
https://fmod.com/docs/2.00/api/studio-api-eventinstance.html#studio_eventinstance_setparameterbyname

If the event has no parameter matching name then FMOD_ERR_EVENT_NOTFOUND is returned.

I never got that error when calling setParameterByName, even when I passed a keyboard smash as the name argument (to see if it ever returned an error), so I couldn’t tell if my parameter was set up incorrectly, it was an error with the name, or something else.

Thank you for sharing the documentation and pointing out my misunderstanding!

Yes, I can definitely see why that was confusing. The reason is that FMOD is designed for performance-critical environments, where logging or throwing exceptions on every small error could cause frame hitches, audio glitches, or CPU spikes.

Instead, FMOD follows a C-style convention: you get a FMOD_RESULT from every API call, and it’s up to the developer to check the result manually.

In other words, FMOD expects you to write something like:

FMOD.RESULT result = eventInstance.setParameterByName("NonexistentParam", 0.5f);
if (result != FMOD.RESULT.OK)
{
    UnityEngine.Debug.LogWarning($"FMOD error: {result}"); 
   // This would return FMOD_ERR_EVENT_NOTFOUND
}

Hope this clears things up, let me know if you have questions.