Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

0 votes
Everything seems to work correctly.But my rtpcValue won't update from default.

I am able to set my rtpc value through SetRTPCValue.
I can hear that the RTPC is working.
GetRTPCValue accapts my default value.
AKRESULT is debugging me "successfull"
I am using the RTPCValue_Global type, which should ignore both in_gameObjectID and in_playingID.

But still my float rtpcValue won't update. Have anybody encountered that problem before?

This is my code:

    float rtpcValue;
    public string rtpcID = "rtpc_sunrise";
    public string in_playingID;
    int type1 = 1;

  void Update ()
    {

        if (Input.GetKey(KeyCode.Alpha7))
        {
            AkSoundEngine.SetRTPCValue(rtpcID, 0);
        }

        if (Input.GetKey(KeyCode.Alpha8))
        {
            AkSoundEngine.SetRTPCValue(rtpcID, 90);
        }

        AKRESULT result = AkSoundEngine.GetRTPCValue(rtpcID, gameObject, 0, out rtpcValue, ref type1);
        Debug.Log("Reult: " + result.ToString() + " value " + rtpcValue);
    }
in General Discussion by M. Riddersholm (230 points)

1 Answer

0 votes

Hi,

the AkSoundEngine.GetRTPCValue function can modify the value of your type1 variable if the value is not found on the scope requested, which probably happens on your first Update() execution since the RTPC doesn't seem to be assigned yet.

Since the scope of that variable is bigger than the Update function, all future GetRTPCValue calls will be made with the incorrect type1 value, most likely requesting the DefaultValue instead of the GlobalValue.

 

I would advise declaring that variable inside the scope of your Update function and preferably right before using it, like so:

 

void Update()

{

    ...

 

    int valueType = (int)AkQueryRTPCValue.RTPCValue_Global;  // 1 like your type1 variable

    AKRESULT result = AkSoundEngine.GetRTPCValue(rtpcID, null, 0, out rtpcValue, ref valueType);

}

 

If you want to confirm this, you can output the value of your type1 variable in your log along with the rtpc value

Cheerz

by Martin S. (590 points)
Hi Martin

Thank you for the answer.

I figured it out myself, with the help of my programmor.
But I didn't manage to figure out why excatly RTPCtype is set with a ref in the GetRTPCValue method.
Why excatly is that? why would you ever need the type to be set to default by itself?
The function starts by trying to find the rtpc value at the scope requested. If the value is not found, it tries a more general scope until it finds it.

Once the function returns, you can test valueType again to know the scope of the value returned.
...