# Returned global parameter value not what it should be

**URL:** <https://qa.fmod.com/t/returned-global-parameter-value-not-what-it-should-be/21861>\
**Category:** FMOD Engine\
**Tags:** cpp\
**Created:** [July 10, 2024, 1:54pm UTC](https://qa.fmod.com/t/returned-global-parameter-value-not-what-it-should-be/21861 "2024-07-10T13:54:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Jan](https://qa.fmod.com/u/Jan)\
**Post date:** [July 10, 2024, 1:54pm UTC](https://qa.fmod.com/t/returned-global-parameter-value-not-what-it-should-be/21861/1 "2024-07-10T13:54:45Z")

</div>

I’ve added a global parameter “TrackNumber”.  
In an event I have all my music tracks one after another and use this parameter to select the active one:

 ![grafik](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/30d318cfc5779c839adf8f8f9255eb8a13e4b1cb.png)

Each track is a nested event. When it’s finished, a command instrument increases the TrackNumber value by one:

![grafik](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/a/a1f0729cd021d6d3a062bf41517abb8df4b47c28.png)

This way I’m getting a nicely playing track playlist, but I’m also able to select the active track from code by just setting the TrackNumber parameter directly.

However, since the tracks increase the global parameter automatically at the end, to then manually skip to the next track, I first need to get the value of the global parameter, because my C++ code can’t know how often the tracks already automatically increased the parameter value.

And this is where it’s getting weird.

I call `System::getParameterByName` to retrieve the value, but it seems to be de-synced from the actual value used by the event. I can change it via `System::setParameterByName` and that DOES change the active track, and I can then call `System::getParameterByName` and it DOES give me the previously set value, however, if the value is modified by the command instrument inside the event, it DOES advance to the next track, but the value returned by `System::getParameterByName` does NOT change.

So I don’t know which track fmod is actually currently playing.

Is this supposed to work? Anything obvious that I might be doing wrong?

Edit: This is with FMOD 2.02.20. I’ve looked at the release notes but didn’t see any fixes around global parameters being mentioned in newer versions.

---

<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:** [July 12, 2024, 3:40am UTC](https://qa.fmod.com/t/returned-global-parameter-value-not-what-it-should-be/21861/2 "2024-07-12T03:40:13Z")

</div>

The `value` argument of [`getParameterByName`](https://www.fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_getparameterbyname) is the value as set from the public API. The `finalvalue` argument is the final value of parameter calculated by the Studio system based on value set via the API and changes from the system itself like automation, modulation, command instruments, etc.

Try retrieving `finalvalue` instead of `value` and see whether its value lines up with what you expect based on how your event is set up.

---

<div class="post-metadata">

**Author:** ![Jan](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@Jan](https://qa.fmod.com/u/Jan)\
**Post date:** [July 12, 2024, 7:59pm UTC](https://qa.fmod.com/t/returned-global-parameter-value-not-what-it-should-be/21861/3 "2024-07-12T19:59:12Z")

</div>

That works, thank you!
