How to use getParameterByName

Sorry that I am a bit new but I really dont understand how these arguments with ‘out’ works. It seems to return more values to a variable I set, but still I cant make it work, or dont use the second argument I had the impression the second argument would be optional but it throws an error without it…

This is what is the error :

        float value_b;
        float value_a;
        value_a =  Music.getParameterByName("Music Parameter 1", out value_b);

The value of the parameter will be stored in the “out” variable. You probably have to remove “value a =”, in your exemple.
(I may be wrong, though.)

2 Likes

Hi,

Alcibiade is correct. Just a few things to add on.
The return result of most FMOD functions is FMOD_RESULT which is a super useful debugging tool. A full list of Results is under FMOD API | Core API Reference. How you would want to change your function is:

FMOD.RESULT result =  Music.getParameterByName("Music Parameter 1", out value_b);
/* Then you can check if the function ran successfully. */
if (result != FMOD.RESULT.OK)
    Debug.Log("Get Parameter by named failed with result: " + result); 

This is a useful way to use the result return to debug FMOD.

Hope that helps!

1 Like

Thanks for the solution Alicibiade it worked nice here. Thanks for the information Connor that is very good to know!

1 Like