# Accessing Inbuilt Parameters via API

**URL:** https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487
**Category:** Unity
**Tags:** unity, csharp
**Created:** [November 7, 2022, 5:28pm UTC](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487 "2022-11-07T17:28:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![NiccoloGranieri](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@NiccoloGranieri](https://qa.fmod.com/u/NiccoloGranieri)
#### Post date: [November 7, 2022, 5:28pm UTC](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487/1 "2022-11-07T17:28:11Z")

</div>

Hello,

I am trying to “expose” FMOD’s inbuilt parameters for educational reasons. I have recently built a very simple game level where distance, direction, elevation and event cone angle are displayed in game letting the student not only “hear” the changes in sound but also “see” the parameters change to have a better understanding of the parameters themselves.

To achieve this, I have calculated these parameters manually using the player and emitting object’s transform. However, I struggle to believe there is no way to get the FMOD inbuilt parameters from a Unity script and display them.

The API Docs say that " [Studio::EventInstance::get3DAttributes](https://fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_get3dattributes)" will return some vectors, which is not really what I need.

Has anyone attempted this before?

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [November 8, 2022, 10:00pm UTC](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487/2 "2022-11-08T22:00:42Z")

</div>

You can indeed get FMOD’s built-in parameters from a Unity script - the methods you’re looking for are [Studio::EventInstance::getParameterByName](https://fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_getparameterbyname) and [Studio::EventInstance::getParameterByID](https://fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_getparameterbyid), both of which will return the value of a built-in parameter to the 3rd argument, `finalvalue`.

---

<div class="post-metadata">

### Author: ![NiccoloGranieri](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@NiccoloGranieri](https://qa.fmod.com/u/NiccoloGranieri)
#### Post date: [November 9, 2022, 9:44am UTC](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487/3 "2022-11-09T09:44:51Z")

</div>

Hi @Leah_FMOD, thanks for the reply.

I have tried the two methods above, and whilst I can get “a” value from the FMOD Instance, this value is always stuck at the maximum value for a floating point (3.40282347E+38) which is weird because the FMOD event works, and as I approach the cube that holds the script, the attenuation curve is clearly having an effect on the sound. Any ideas what I might be doing wrong?

```auto
public class Test : MonoBehaviour
{
    private FMOD.Studio.EventInstance instance;

    float outvalue;

    void Update()
    {
        GetCubeTransform();

        if (Input.GetKeyDown("p"))
        {
            instance = FMODUnity.RuntimeManager.CreateInstance("event:/Distanza");
            instance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(cubeTransform));
            instance.start();
            instance.getParameterByName("Distance", out outvalue);
            Debug.Log(outvalue);
            instance.release();
        }
    }

    void GetCubeTransform(){
        GameObject cube = GameObject.Find("Cubo_Distanza");
        if (cube != null) {
            cubeTransform = cube.transform;
        }
    }
}

```

---

<div class="post-metadata">

### Author: ![NiccoloGranieri](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@NiccoloGranieri](https://qa.fmod.com/u/NiccoloGranieri)
#### Post date: [November 9, 2022, 2:36pm UTC](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487/4 "2022-11-09T14:36:34Z")

</div>

I simplified the code even more, using some a suggested implementation found [here](https://qa.fmod.com/t/example-of-getparametervalue/17978), and now I get 3.40282347E+38 when trying to access parameterValue, and 0 when trying to access finalParameterValue.

```auto
    float parameterValue;
    float finalParameterValue;
    public FMODUnity.EventReference eventRef;
    FMOD.Studio.EventInstance eventInst;

    void Start()
    {
        eventInst = FMODUnity.RuntimeManager.CreateInstance(eventRef);
    }

    void Update()
    {
        eventInst.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
        eventInst.getParameterByName("Distance", out parameterValue, out finalParameterValue);
        Debug.Log($"FPV {finalParameterValue}");
    }

```

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [November 10, 2022, 3:21am UTC](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487/5 "2022-11-10T03:21:23Z")

</div>

The simplified code is missing calls to `eventInst.start()` and `eventInst.release()`. Add them, and `getParameterByName` should output what you’re looking for to `finalParameterValue`.

Built-in parameter values are automatically updated based on the 3D attributes of the associated event instance and the listeners in your scene - the `value` of a built-in parameter is never used and should be set to 0 by default (that it’s set to float max is a bug we’re working on). Likewise, attempting to set the `value` of a built-in parameter yourself will cause an error.

`finalvalue` is the value of a given parameter after it has been adjusted by automation, modulation, seek speed, etc. by FMOD. For built-in parameters, `finalvalue` has the data that you want.

Hope that helps!

---

<div class="post-metadata">

### Author: ![NiccoloGranieri](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@NiccoloGranieri](https://qa.fmod.com/u/NiccoloGranieri)
#### Post date: [November 10, 2022, 8:31am UTC](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487/6 "2022-11-10T08:31:28Z")

</div>

Thank you @Leah_FMOD !
