How to get a list of all of a parameter's lables

Hey all,

A pattern I like to do for handling game ambience sound is to have a singular ambience event that is always playing and then have a label parameter on it that gets set depending on which ambience effects you want to be playing.

I am attempting to auto generate an Enum of all possible labels for this parameter to avoid string comparison issues and just make the process a little bit easier for our sound and level designers. Is there a way I can get a list of all valid IDs or values for a PARAMETER_DESCRIPTION struct. It is pretty straight forward to get the parameter itself from the event instance, but I am struggling to see how to find a list of valid values that the parameter can be set in.

This data definitely exists as I can see the name and ID appear in the metadata for the parameter when i add new labels to the parmeter in fmod studio, but I am struggling to get this data to my unity editor script to bake out the enum. Push comes to shove I can probably find and read directly from the parameter meta data .xml file but I would like to avoid that for the sake of this tool’s future maintainability.

TL;DR is a list of the valid label values of a parameter exposed unity side in any way or do i have to parse the metadata xml to obtain this data. I will be running this script in editor (doesn’t need to work during runtime).

My bad if a thread for this exists, i did a search but only found people searching for a list of all parameters (which I am able to do), not a list of all label values within a parameter.

EDIT: so it looks like I can get a label by index from the parameter. Now i think the last piece of the puzzle I need to find is how to figure out the number of labels in the parameter (so i can iterate through all indices and get them all)

EDIT 2: Was able to roughly accomplish this with a (fairly jank) while loop. If there is a way to find the count of the labels on a parameter that would be cleaner. Posting pseudocode in case anyone else has a similar question. it errors that the last index is invalid (cpp plugin side), which isn’t great, but is fine for an editor only script for now.

public static void GetParamEnums(EventReference e, string paramName) {
            EventDescription eventDescription = RuntimeManager.GetEventDescription(e);
            if (eventDescription.isValid()) {
                PARAMETER_DESCRIPTION param ;
                FMOD.RESULT paramResult = eventDescription.getParameterDescriptionByName(paramName, out param);
                Debug.Log("Result was: " + paramResult.ToString());

                bool exitCase = false;
                List<string> labelList = new List<string>();
                int itr = 0;

                while (!exitCase) {
                    string toAdd = null;
                    FMOD.RESULT result = eventDescription.getParameterLabelByID(param.id, itr, out toAdd);
                    if (result == FMOD.RESULT.OK) {
                        labelList.Add(toAdd);
                        itr++;
                    }
                    else {
                        exitCase = true;
                    }
                }
        }

You should be able to use EventDescription.getParameterDescriptionCount(out int count) and then loop through the parameter with EventDescription.getParameterLabelByID(int id, out string) to get a list of all parameter labels.

https://www.fmod.com/resources/documentation-api?version=2.02&page=studio-api-eventdescription.html#studio_eventdescription_getparameterdescriptioncount

https://www.fmod.com/resources/documentation-api?version=2.02&page=studio-api-eventdescription.html#studio_eventdescription_getparameterlabelbyid

1 Like

tyty, much cleaner.

oh actually I dont believe that would work. Tthe getParameterDescriptionCount would return a count of all the parameters on the event. this event has both label parameters and other parameters but I only want to iterate through the labels. Its like i want a count of the labels on a single parameter, not the count of all the parameters on the event.

What i really want is like a ‘GetLabelCount’ function to call on the specific parameter. in my project getParameterDescriptionCount returns 3 (which is the number of parameters on the event) but the count of labels on the first parameter (what im iterating through) is 52.

Ah you are correct, I misread the documentation sorry.

Instead what you can do is to get the parameter description and then check the parameter descriptions maximum value. It returns a float, but each whole number (eg. 1.00, 2.00) is a label. You can then use getParameterLabelByID to get the labels as strings.

https://www.fmod.com/resources/documentation-api?version=2.02&page=studio-api-eventdescription.html#studio_eventdescription_getparameterdescriptionbyname

https://www.fmod.com/resources/documentation-api?version=2.02&page=studio-api-common.html#fmod_studio_parameter_description_maximum

1 Like

works perfectly tyvm!