diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 55b23e45..f108c869 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -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", diff --git a/src/utils/fluid_settings.c b/src/utils/fluid_settings.c index 72a096c1..63d34a13 100644 --- a/src/utils/fluid_settings.c +++ b/src/utils/fluid_settings.c @@ -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 * diff --git a/src/utils/fluid_settings.h b/src/utils/fluid_settings.h index 65f23280..6eef5896 100644 --- a/src/utils/fluid_settings.h +++ b/src/utils/fluid_settings.h @@ -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,