Replacement for Deprecated ParameterInstance

Hey friends!

Someone at our company previously wrote a wrapper to handle our connection to FMOD. I’m not quite used to working this way, so it’s taken me some time to get into replacing functions and updating our FMOD. We were on 1.04 and are now finally on latest, however ParameterInstance has deprecated, leaving me high and dry when it comes to working out how to change parameters.

Here is our wrapper as it stands (no longer working)

    public class AudioParameter
{
    FMOD.Studio.EventInstance _parameter;
    string _parameterName;
    public float value
    {
        get
        {
            FMOD.RESULT result = _parameter.getParameterByName(_parameterName, out float v);
            if (result != FMOD.RESULT.OK)
            {
                Debug.LogErrorFormat("FMOD: Failed to get parameter: {0}", result);
                return 0;
            }
            return v;
        }
        set
        {
            //Deprecated from 1.10
            //FMOD.RESULT result = _parameter.setValue(value);
            FMOD.RESULT result = _parameter.setParameterByName(_parameterName, value);
            if (result != FMOD.RESULT.OK)
                Debug.LogErrorFormat("FMOD: Failed to set parameter: {0}", result);
        }
    }

    internal AudioParameter(FMOD.Studio.EventInstance parameter)
    {
        _parameter = parameter;
    }
}

However, we of course get a “FMOD: Failed to set parameter: ERR_INVALID_PARAM” error because, I’d assume, I’m not calling these functions correctly.

Can anyone please enlighten me as to how I can adapt this wrapper to get parameters working?

We normally call them like this;

AudioParameter uiHoldPosition;

uiHoldPosition.value = Progress

Thank you technical saviours!

I’m not seeing anything immediately wrong with the code you have, I’d suggest switching to the logging version of FMOD, it prints additional information about what parameter is invalid. Also I’d double check the _parameterName is valid.

The direct replacement for ParameterInstance is FMOD_STUDIO_PARAMETER_ID which can be fetched directly from the FMOD_STUDIO_PARAMETER_DESCRIPTION. That said what you’re doing is valid too.