Scripting API: discrete parameter's maximum range value not returning correct value. Bug?

(Tested in FMOD 2.01.08)

When I try to get the maximum value from a discrete parameter, I’m getting it’s value incremented by 1.
When it’s continuous, this problem doesn’t happen though.

The following snippet demonstrates my issue, where the parameter’s type & range are in its name for convenience:

studio.project.model.Event.findInstances().forEach(function(e){
     e.getParameterPresets().forEach(function(p){
	console.log('name - ' + p.presetOwner.name);
	console.log('min - ' + p.minimum);
	console.log('max - ' + p.maximum);
	console.log('type - ' + p.parameterType);
	console.log('=================================================================');
     });
})

Returns:

name - p_continuous_0-1
min - 0
max - 1
type - 0
=================================================================
name - p_continuous_1-2
min - 1
max - 2
type - 0
=================================================================
name - p_discrete_0-1
min - 0
max - 2
type - 1
=================================================================
name - p_discrete_1-2
min - 1
max - 3
type - 1
=================================================================

Is this a bug?

Hi, since discrete values are whole integers, it makes sense if it is giving the non-inclusive max value.

No, but I can see why you might think it is.

Under-the-hood, discrete parameters are floating point variables rather than integers, in order to support features such as parameter velocity, seek speed, and parameter value modulation, that gradually change parameter values over time. This means that each value of a discrete parameter is actually a range of values one unit long: the value 1 is the range of values from 1-2, the value 2 is the range of values from 2-3, and so on. Thus, a parameter whose maximum settable value is 2 actually runs all the way to 3.

1 Like

I stand corrected, thank you for this explanation.

Oh, I see! Thanks for explaining :slight_smile: