mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-02 17:12:15 +00:00
Add float-typed wrapper for fluid_settings_getnum
Avoids the need to store the value in a local double before assigning it to the target variable.
This commit is contained in:
parent
ac5aa418ae
commit
3973b9566d
3 changed files with 30 additions and 14 deletions
|
@ -515,8 +515,6 @@ new_fluid_synth(fluid_settings_t *settings)
|
|||
{
|
||||
fluid_synth_t* synth;
|
||||
fluid_sfloader_t* loader;
|
||||
double gain;
|
||||
double num_val;
|
||||
int i, nbuf;
|
||||
int with_ladspa = 0;
|
||||
|
||||
|
@ -569,21 +567,15 @@ new_fluid_synth(fluid_settings_t *settings)
|
|||
fluid_settings_getint(settings, "synth.audio-channels", &synth->audio_channels);
|
||||
fluid_settings_getint(settings, "synth.audio-groups", &synth->audio_groups);
|
||||
fluid_settings_getint(settings, "synth.effects-channels", &synth->effects_channels);
|
||||
fluid_settings_getnum(settings, "synth.gain", &gain);
|
||||
synth->gain = gain;
|
||||
fluid_settings_getnum_float(settings, "synth.gain", &synth->gain);
|
||||
fluid_settings_getint(settings, "synth.device-id", &synth->device_id);
|
||||
fluid_settings_getint(settings, "synth.cpu-cores", &synth->cores);
|
||||
|
||||
fluid_settings_getnum(settings, "synth.overflow.percussion", &num_val);
|
||||
synth->overflow.percussion = num_val;
|
||||
fluid_settings_getnum(settings, "synth.overflow.released", &num_val);
|
||||
synth->overflow.released = num_val;
|
||||
fluid_settings_getnum(settings, "synth.overflow.sustained", &num_val);
|
||||
synth->overflow.sustained = num_val;
|
||||
fluid_settings_getnum(settings, "synth.overflow.volume", &num_val);
|
||||
synth->overflow.volume = num_val;
|
||||
fluid_settings_getnum(settings, "synth.overflow.age", &num_val);
|
||||
synth->overflow.age = num_val;
|
||||
fluid_settings_getnum_float(settings, "synth.overflow.percussion", &synth->overflow.percussion);
|
||||
fluid_settings_getnum_float(settings, "synth.overflow.released", &synth->overflow.released);
|
||||
fluid_settings_getnum_float(settings, "synth.overflow.sustained", &synth->overflow.sustained);
|
||||
fluid_settings_getnum_float(settings, "synth.overflow.volume", &synth->overflow.volume);
|
||||
fluid_settings_getnum_float(settings, "synth.overflow.age", &synth->overflow.age);
|
||||
|
||||
/* register the callbacks */
|
||||
fluid_settings_callback_num(settings, "synth.sample-rate",
|
||||
|
|
|
@ -1249,6 +1249,27 @@ fluid_settings_getnum(fluid_settings_t* settings, const char *name, double* val)
|
|||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* float-typed wrapper for fluid_settings_getnum
|
||||
*
|
||||
* @param settings a settings object
|
||||
* @param name a setting's name
|
||||
* @param val variable pointer to receive the setting's float value
|
||||
* @return #FLUID_OK if the value exists, #FLUID_FAILED otherwise
|
||||
*/
|
||||
int fluid_settings_getnum_float(fluid_settings_t *settings, const char *name, float *val)
|
||||
{
|
||||
double tmp;
|
||||
|
||||
if (fluid_settings_getnum(settings, name, &tmp) == FLUID_OK)
|
||||
{
|
||||
*val = tmp;
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the range of values of a numeric setting
|
||||
*
|
||||
|
|
|
@ -40,6 +40,9 @@ int fluid_settings_register_num(fluid_settings_t* settings, const char* name, do
|
|||
int fluid_settings_callback_num(fluid_settings_t* settings, const char* name,
|
||||
fluid_num_update_t fun, void* data);
|
||||
|
||||
/* Type specific wrapper for fluid_settings_getnum */
|
||||
int fluid_settings_getnum_float(fluid_settings_t *settings, const char *name, float *val);
|
||||
|
||||
|
||||
typedef void (*fluid_int_update_t)(void* data, const char* name, int value);
|
||||
int fluid_settings_register_int(fluid_settings_t* settings, const char* name, int def,
|
||||
|
|
Loading…
Reference in a new issue