Fix return in fluid_synth_chorus_set_param(), fluid_synth_reverb_set_param() (#789)

This commit is contained in:
jjceresa 2021-03-04 21:47:59 +01:00 committed by GitHub
parent 73182866e0
commit e4241469d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 5 deletions

View file

@ -1406,6 +1406,13 @@ fluid_handle_chorus_command(void *data, int ac, char **av, fluid_ostream_t out,
static const char *const name_value[FLUID_CHORUS_PARAM_LAST - 1] =
{"nr", "level", "speed", "depth"};
/* setting name (except lfo waveform type) */
static const char *name[FLUID_CHORUS_PARAM_LAST-1] =
{
"synth.chorus.nr", "synth.chorus.level",
"synth.chorus.speed", "synth.chorus.depth"
};
FLUID_ENTRY_COMMAND(data);
/* get and check index fx group index argument */
@ -1424,16 +1431,35 @@ fluid_handle_chorus_command(void *data, int ac, char **av, fluid_ostream_t out,
return FLUID_FAILED;
}
/* run chorus function */
if(param == FLUID_CHORUS_NR) /* commands with integer parameter */
{
value = (double)atoi(av[ac]);
int min, max;
int int_value = atoi(av[ac]);
fluid_settings_getint_range(handler->settings, name[param], &min, &max);
if(int_value < min || int_value > max)
{
fluid_ostream_printf(out, "%s: %s \"%s\" must be in range [%d..%d]\n",
name_cde[param], name_value[param], av[ac], min, max);
return FLUID_FAILED;
}
value = (double)int_value;
}
else /* commands with float parameter */
{
double min, max;
value = atof(av[ac]);
fluid_settings_getnum_range(handler->settings, name[param], &min, &max);
if(value < min || value > max)
{
fluid_ostream_printf(out, "%s: %s \"%s\" must be in range [%f..%f]\n",
name_cde[param], name_value[param], av[ac], min, max);
return FLUID_FAILED;
}
}
/* run chorus function */
fluid_synth_chorus_set_param(handler->synth, fx_group, param, value);
return FLUID_OK;
}

View file

@ -5922,7 +5922,10 @@ fluid_synth_reverb_set_param(fluid_synth_t *synth, int fx_group,
/* check if reverb value is in max min range */
fluid_settings_getnum_range(synth->settings, name[param], &min, &max);
fluid_return_val_if_fail( min <= value && value <= max, FLUID_FAILED);
if(value < min || value > max)
{
FLUID_API_RETURN(FLUID_FAILED);
}
/* set the value */
values[param] = value;
@ -6407,14 +6410,20 @@ fluid_synth_chorus_set_param(fluid_synth_t *synth, int fx_group, int param,
{
fluid_settings_getint_range(synth->settings, name[param], &min, &max);
}
fluid_return_val_if_fail(min <= (int)value && (int)value <= max, FLUID_FAILED);
if((int)value < min || (int)value > max)
{
FLUID_API_RETURN(FLUID_FAILED);
}
}
else /* float value */
{
double min;
double max;
fluid_settings_getnum_range(synth->settings, name[param], &min, &max);
fluid_return_val_if_fail(min <= value && value <= max, FLUID_FAILED);
if(value < min || value > max)
{
FLUID_API_RETURN(FLUID_FAILED);
}
}
/* set the value */