Hello, I’m working on a system that needs to be able to set both global and local parameters using the same function. Currently I am trying to set the parameter and if it fails because it is a global parameter I then use the Studio System. Is there a way to check if an event is global or local first rather than having to try and catch the failure. I’d like to not have the error message from CHECKERR() print out if it is not needed. Below is my current code. Thanks!
FMOD_RESULT result;
// try and set the parameter as if it is local to the event
result = eventInstance->setParameterByName(paramName.c_str(), value);
ERRCHECK(result);
// if this failed see if it is a global parameter
if (result == FMOD_ERR_INVALID_PARAM){
result = studioSystem->setParameterByName(paramName.c_str(), value);
ERRCHECK(result);
}
This seems like as good a way as any of testing if a parameter is global or not- I couldn’t find any nice API hooks for determining whether a parameter is global or not.
In terms of not printing an error if it’s not needed, you do not need to use ERRCHECK for the first call
FMOD_RESULT result;
result = eventInstance->setParameterByName(paramName.c_str(), value);
if (result == FMOD_ERR_INVALID_PARAM){
result = studioSystem->setParameterByName(paramName.c_str(), value);
}
ERRCHECK(result);
Edit: We do have a nicer way of finding this out- EventDescription::getParameterDescriptionByName
returns an FMOD_STUDIO_PARAMETER_DESCRIPTION
struct, and on that the flags
member can be &'d against FMOD_STUDIO_PARAMETER_GLOBAL
to determine if it’s global or not.
2 Likes
Thank you @jeff_fmod for the help. I think the EventDescription method is the way I’ll do it. Thanks again!