mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-11 13:21:03 +00:00
Fix return in fluid_synth_chorus_set_param(), fluid_synth_reverb_set_param() (#789)
This commit is contained in:
parent
73182866e0
commit
e4241469d4
2 changed files with 40 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue