diff --git a/bindings/fluidmax/fluidmax.c b/bindings/fluidmax/fluidmax.c index 06617bd1..fc6b3929 100644 --- a/bindings/fluidmax/fluidmax.c +++ b/bindings/fluidmax/fluidmax.c @@ -821,8 +821,8 @@ fluidmax_chorus(t_object *o, Symbol *s, short ac, Atom *at) } else if(ftmax_is_number(at)) { - double speed = fluid_synth_get_chorus_speed_Hz(self->synth); - double depth = fluid_synth_get_chorus_depth_ms(self->synth); + double speed = fluid_synth_get_chorus_speed(self->synth); + double depth = fluid_synth_get_chorus_depth(self->synth); int type = fluid_synth_get_chorus_type(self->synth); int nr = fluid_synth_get_chorus_nr(self->synth); @@ -1267,8 +1267,8 @@ fluidmax_print(t_object *o, Symbol *s, short ac, Atom *at) if(self->chorus != 0) { double level = fluid_synth_get_chorus_level(self->synth); - double speed = fluid_synth_get_chorus_speed_Hz(self->synth); - double depth = fluid_synth_get_chorus_depth_ms(self->synth); + double speed = fluid_synth_get_chorus_speed(self->synth); + double depth = fluid_synth_get_chorus_depth(self->synth); int type = fluid_synth_get_chorus_type(self->synth); int nr = fluid_synth_get_chorus_nr(self->synth); @@ -1477,8 +1477,8 @@ fluidmax_info(t_object *o, Symbol *s, short ac, Atom *at) if(self->chorus != 0) { double level = fluid_synth_get_chorus_level(self->synth); - double speed = fluid_synth_get_chorus_speed_Hz(self->synth); - double depth = fluid_synth_get_chorus_depth_ms(self->synth); + double speed = fluid_synth_get_chorus_speed(self->synth); + double depth = fluid_synth_get_chorus_depth(self->synth); int type = fluid_synth_get_chorus_type(self->synth); int nr = fluid_synth_get_chorus_nr(self->synth); ftmax_atom_t a[5]; diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index 6144fa68..378d7442 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -42,6 +42,42 @@ Developers: Settings can be deprecated by adding: SOME TEXT When set to 1 (TRUE) the chorus effects module is activated. Otherwise, no chorus will be added to the output signal. Note that the amount of signal sent to the chorus module depends on the "chorus send" generator defined in the SoundFont. + + chorus.depth + num + 8 + 0 + 21 + + Specifies the modulation depth of the chorus. + + + chorus.level + num + 2 + 0 + 10 + + Specifies the output amplitude of the chorus signal. + + + chorus.nr + int + 3 + 0 + 99 + + Sets the voice count of the chorus. + + + chorus.speed + num + 0.3 + 0.29 + 5 + + Sets the modulation speed in Hz. + cpu-cores int @@ -247,6 +283,42 @@ Developers: Settings can be deprecated by adding: SOME TEXT + + reverb.damp + num + 0 + 0 + 1 + + Sets the amount of reverb damping. + + + reverb.level + num + 0.9 + 0 + 1 + + Sets the reverb output amplitude. + + + reverb.room-size + num + 0.2 + 0 + 1 + + Sets the room size (i.e. amount of wet) reverb. + + + reverb.width + num + 0.5 + 0 + 100 + + Sets the stereo spread of the reverb signal. + sample-rate num diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 5920e9ee..209b1771 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -108,6 +108,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - reverb: roomsize is now limited to an upper threshold of 1.0 to avoid exponential volume increase - use unique device names for the "audio.portaudio.device" setting - rename fluid_mod_new() and fluid_mod_delete() to match naming conventions: new_fluid_mod() and delete_fluid_mod() +- rename chorus getters to match naming conventions: fluid_synth_get_chorus_speed() and fluid_synth_get_chorus_depth() - fluid_synth_remove_sfont() returns FLUID_OK or FLUID_FAILED

- add "midi.autoconnect" a setting for automatically connecting fluidsynth to available MIDI input ports @@ -117,6 +118,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - add fluid_synth_add_default_mod() and fluid_synth_remove_default_mod() for manipulating default modulators - add individual reverb setters: fluid_synth_set_reverb_roomsize(), fluid_synth_set_reverb_damp(), fluid_synth_set_reverb_width(), fluid_synth_set_reverb_level() - add individual chorus setters: fluid_synth_set_chorus_nr(), fluid_synth_set_chorus_level(), fluid_synth_set_chorus_speed(), fluid_synth_set_chorus_depth(), fluid_synth_set_chorus_type() +- add realtime settings for reverb and chorus parameters - introduce a separate data type for sequencer client IDs: #fluid_seq_id_t - add seek support to midi-player, see fluid_player_seek() - expose functions to manipulate the ladspa effects unit (see ladspa.h) diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index 8619477d..72940d42 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -137,11 +137,6 @@ FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t* synth); FLUIDSYNTH_API double fluid_synth_get_reverb_level(fluid_synth_t* synth); FLUIDSYNTH_API double fluid_synth_get_reverb_width(fluid_synth_t* synth); -#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f /**< Default reverb room size */ -#define FLUID_REVERB_DEFAULT_DAMP 0.0f /**< Default reverb damping */ -#define FLUID_REVERB_DEFAULT_WIDTH 0.5f /**< Default reverb width */ -#define FLUID_REVERB_DEFAULT_LEVEL 0.9f /**< Default reverb level */ - /* Chorus */ @@ -164,16 +159,10 @@ FLUIDSYNTH_API int fluid_synth_set_chorus_type(fluid_synth_t* synth, int type); FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t* synth, int on); FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t* synth); FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t* synth); -FLUIDSYNTH_API double fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth); -FLUIDSYNTH_API double fluid_synth_get_chorus_depth_ms(fluid_synth_t* synth); +FLUIDSYNTH_API double fluid_synth_get_chorus_speed(fluid_synth_t* synth); +FLUIDSYNTH_API double fluid_synth_get_chorus_depth(fluid_synth_t* synth); FLUIDSYNTH_API int fluid_synth_get_chorus_type(fluid_synth_t* synth); /* see fluid_chorus_mod */ -#define FLUID_CHORUS_DEFAULT_N 3 /**< Default chorus voice count */ -#define FLUID_CHORUS_DEFAULT_LEVEL 2.0f /**< Default chorus level */ -#define FLUID_CHORUS_DEFAULT_SPEED 0.3f /**< Default chorus speed */ -#define FLUID_CHORUS_DEFAULT_DEPTH 8.0f /**< Default chorus depth */ -#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE /**< Default chorus waveform type */ - /* Audio and MIDI channels */ diff --git a/src/bindings/fluid_cmd.c b/src/bindings/fluid_cmd.c index 12dfa49c..3eccdcc3 100644 --- a/src/bindings/fluid_cmd.c +++ b/src/bindings/fluid_cmd.c @@ -803,6 +803,9 @@ fluid_handle_reverbpreset(void* data, int ac, char** av, fluid_ostream_t out) { FLUID_ENTRY_COMMAND(data); int reverb_preset_number; + + fluid_ostream_printf(out, "rev_preset is deprecated and will be removed in a future release!\n"); + if (ac < 1) { fluid_ostream_printf(out, "rev_preset: too few arguments\n"); return FLUID_FAILED; @@ -823,10 +826,14 @@ fluid_handle_reverbsetroomsize(void* data, int ac, char** av, fluid_ostream_t ou { FLUID_ENTRY_COMMAND(data); fluid_real_t room_size; + if (ac < 1) { fluid_ostream_printf(out, "rev_setroomsize: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "rev_setroomsize is deprecated! Use 'set synth.reverb.room-size %s' instead.\n", av[0]); + room_size = atof(av[0]); if (room_size < 0){ fluid_ostream_printf(out, "rev_setroomsize: Room size must be positive!\n"); @@ -852,6 +859,9 @@ fluid_handle_reverbsetdamp(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "rev_setdamp: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "rev_setdamp is deprecated! Use 'set synth.reverb.damp %s' instead.\n", av[0]); + damp = atof(av[0]); if ((damp < 0.0f) || (damp > 1)){ fluid_ostream_printf(out, "rev_setdamp: damp must be between 0 and 1!\n"); @@ -873,6 +883,9 @@ fluid_handle_reverbsetwidth(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "rev_setwidth: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "rev_setroomsize is deprecated! Use 'set synth.reverb.width %s' instead.\n", av[0]); + width = atof(av[0]); if ((width < 0) || (width > 100)){ fluid_ostream_printf(out, "rev_setroomsize: Too wide! (0..100)\n"); @@ -894,6 +907,9 @@ fluid_handle_reverbsetlevel(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "rev_setlevel: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "rev_setlevel is deprecated! Use 'set synth.reverb.level %s' instead.\n", av[0]); + level = atof(av[0]); if (fabs(level) > 30){ fluid_ostream_printf(out, "rev_setlevel: Value too high! (Value of 10 =+20 dB)\n"); @@ -914,7 +930,9 @@ fluid_handle_reverb(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "reverb: too few arguments.\n"); return FLUID_FAILED; } - + + fluid_ostream_printf(out, "reverb is deprecated! Use 'set synth.reverb.active %s' instead.\n", av[0]); + if ((FLUID_STRCMP(av[0], "0") == 0) || (FLUID_STRCMP(av[0], "off") == 0)) { fluid_synth_set_reverb_on(handler->synth,0); } else if ((FLUID_STRCMP(av[0], "1") == 0) || (FLUID_STRCMP(av[0], "on") == 0)) { @@ -939,6 +957,9 @@ fluid_handle_chorusnr(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "cho_set_nr: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "cho_set_nr is deprecated! Use 'set synth.chorus.nr %s' instead.\n", av[0]); + nr = atoi(av[0]); fluid_synth_set_chorus_nr(handler->synth, nr); return FLUID_OK; @@ -955,6 +976,9 @@ fluid_handle_choruslevel(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "cho_set_level: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "cho_set_level is deprecated! Use 'set synth.chorus.level %s' instead.\n", av[0]); + level = atof(av[0]); fluid_synth_set_chorus_level(handler->synth, level); return FLUID_OK; @@ -972,6 +996,9 @@ fluid_handle_chorusspeed(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "cho_set_speed: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "cho_set_speed is deprecated! Use 'set synth.chorus.speed %s' instead.\n", av[0]); + speed = atof(av[0]); fluid_synth_set_chorus_speed(handler->synth, speed); return FLUID_OK; @@ -988,6 +1015,9 @@ fluid_handle_chorusdepth(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "cho_set_depth: too few arguments.\n"); return FLUID_FAILED; } + + fluid_ostream_printf(out, "cho_set_depth is deprecated! Use 'set synth.chorus.depth %s' instead.\n", av[0]); + depth = atof(av[0]); fluid_synth_set_chorus_depth(handler->synth, depth); return FLUID_OK; @@ -1001,7 +1031,9 @@ fluid_handle_chorus(void* data, int ac, char** av, fluid_ostream_t out) fluid_ostream_printf(out, "chorus: too few arguments\n"); return FLUID_FAILED; } - + + fluid_ostream_printf(out, "chorus is deprecated! Use 'set synth.chorus.active %s' instead.\n", av[0]); + if ((FLUID_STRCMP(av[0], "0") == 0) || (FLUID_STRCMP(av[0], "off") == 0)) { fluid_synth_set_chorus_on(handler->synth,0); } else if ((FLUID_STRCMP(av[0], "1") == 0) || (FLUID_STRCMP(av[0], "on") == 0)) { diff --git a/src/rvoice/fluid_chorus.c b/src/rvoice/fluid_chorus.c index 053ceac1..06799644 100644 --- a/src/rvoice/fluid_chorus.c +++ b/src/rvoice/fluid_chorus.c @@ -220,11 +220,7 @@ fluid_chorus_init(fluid_chorus_t* chorus) for (i = 0; i < MAX_SAMPLES; i++) { chorus->chorusbuf[i] = 0.0; } - - /* initialize the chorus with the default settings */ - fluid_chorus_set (chorus, FLUID_CHORUS_SET_ALL, FLUID_CHORUS_DEFAULT_N, - FLUID_CHORUS_DEFAULT_LEVEL, FLUID_CHORUS_DEFAULT_SPEED, - FLUID_CHORUS_DEFAULT_DEPTH, FLUID_CHORUS_DEFAULT_TYPE); + return FLUID_OK; } diff --git a/src/rvoice/fluid_rev.c b/src/rvoice/fluid_rev.c index 5dc0b03a..dc784fe1 100644 --- a/src/rvoice/fluid_rev.c +++ b/src/rvoice/fluid_rev.c @@ -195,11 +195,6 @@ fluid_comb_getfeedback(fluid_comb* comb) #define scaledamp 1.0f #define scaleroom 0.28f #define offsetroom 0.7f -#define initialroom 0.5f -#define initialdamp 0.2f -#define initialwet 1 -#define initialdry 0 -#define initialwidth 1 #define stereospread 23 /* @@ -278,7 +273,6 @@ new_fluid_revmodel(fluid_real_t sample_rate) fluid_allpass_setfeedback(&rev->allpassR[3], 0.5f); rev->gain = fixedgain; - fluid_revmodel_set(rev,FLUID_REVMODEL_SET_ALL,initialroom,initialdamp,initialwidth,initialwet); return rev; } diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 74602515..1bf2ffd7 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -126,6 +126,8 @@ static void fluid_synth_handle_device_id(void *data, const char *name, int value static void fluid_synth_handle_overflow(void *data, const char *name, double value); static void fluid_synth_handle_important_channels(void *data, const char *name, const char *value); +static void fluid_synth_handle_reverb_chorus_num (void *data, const char *name, double value); +static void fluid_synth_handle_reverb_chorus_int (void *data, const char *name, int value); static void fluid_synth_reset_basic_channel_LOCAL(fluid_synth_t* synth, int chan, int nbr_chan); @@ -134,6 +136,8 @@ static void fluid_synth_set_basic_channel_LOCAL(fluid_synth_t* synth, int basicc static int fluid_synth_set_reverb_full_LOCAL(fluid_synth_t* synth, int set, double roomsize, double damping, double width, double level); +static int fluid_synth_set_chorus_full_LOCAL(fluid_synth_t* synth, int set, int nr, double level, + double speed, double depth_ms, int type); /*************************************************************** * @@ -191,8 +195,19 @@ static const fluid_revmodel_presets_t revmodel_preset[] = { void fluid_synth_settings(fluid_settings_t* settings) { fluid_settings_register_int(settings, "synth.verbose", 0, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "synth.reverb.active", 1, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_num(settings, "synth.reverb.room-size", FLUID_REVERB_DEFAULT_ROOMSIZE, 0.0f, 1.0f, 0); + fluid_settings_register_num(settings, "synth.reverb.damp", FLUID_REVERB_DEFAULT_DAMP, 0.0f, 1.0f, 0); + fluid_settings_register_num(settings, "synth.reverb.width", FLUID_REVERB_DEFAULT_WIDTH, 0.0f, 100.0f, 0); + fluid_settings_register_num(settings, "synth.reverb.level", FLUID_REVERB_DEFAULT_LEVEL, 0.0f, 1.0f, 0); + fluid_settings_register_int(settings, "synth.chorus.active", 1, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "synth.chorus.nr", FLUID_CHORUS_DEFAULT_N, 0, 99, 0); + fluid_settings_register_num(settings, "synth.chorus.level", FLUID_CHORUS_DEFAULT_LEVEL, 0.0f, 10.0f, 0); + fluid_settings_register_num(settings, "synth.chorus.speed", FLUID_CHORUS_DEFAULT_SPEED, 0.29f, 5.0f, 0); + fluid_settings_register_num(settings, "synth.chorus.depth", FLUID_CHORUS_DEFAULT_DEPTH, 0.0f, 21.0f, 0); + fluid_settings_register_int(settings, "synth.ladspa.active", 0, 0, 1, FLUID_HINT_TOGGLED); fluid_settings_register_int(settings, "synth.lock-memory", 1, 0, 1, FLUID_HINT_TOGGLED); fluid_settings_register_str(settings, "midi.portname", "", 0); @@ -641,6 +656,26 @@ new_fluid_synth(fluid_settings_t *settings) fluid_synth_handle_overflow, synth); fluid_settings_callback_str(settings, "synth.overflow.important-channels", fluid_synth_handle_important_channels, synth); + fluid_settings_callback_num(settings, "synth.reverb.room-size", + fluid_synth_handle_reverb_chorus_num, synth); + fluid_settings_callback_num(settings, "synth.reverb.damp", + fluid_synth_handle_reverb_chorus_num, synth); + fluid_settings_callback_num(settings, "synth.reverb.width", + fluid_synth_handle_reverb_chorus_num, synth); + fluid_settings_callback_num(settings, "synth.reverb.level", + fluid_synth_handle_reverb_chorus_num, synth); + fluid_settings_callback_int(settings, "synth.reverb.active", + fluid_synth_handle_reverb_chorus_int, synth); + fluid_settings_callback_int(settings, "synth.chorus.active", + fluid_synth_handle_reverb_chorus_int, synth); + fluid_settings_callback_int(settings, "synth.chorus.nr", + fluid_synth_handle_reverb_chorus_int, synth); + fluid_settings_callback_num(settings, "synth.chorus.level", + fluid_synth_handle_reverb_chorus_num, synth); + fluid_settings_callback_num(settings, "synth.chorus.depth", + fluid_synth_handle_reverb_chorus_num, synth); + fluid_settings_callback_num(settings, "synth.chorus.speed", + fluid_synth_handle_reverb_chorus_num, synth); /* do some basic sanity checking on the settings */ @@ -799,12 +834,38 @@ new_fluid_synth(fluid_settings_t *settings) synth->curmax = 0; synth->dither_index = 0; - fluid_synth_set_reverb_full_LOCAL(synth, + { + double room, damp, width, level; + + fluid_settings_getnum(settings, "synth.reverb.room-size", &room); + fluid_settings_getnum(settings, "synth.reverb.damp", &damp); + fluid_settings_getnum(settings, "synth.reverb.width", &width); + fluid_settings_getnum(settings, "synth.reverb.level", &level); + + fluid_synth_set_reverb_full_LOCAL(synth, FLUID_REVMODEL_SET_ALL, - FLUID_REVERB_DEFAULT_ROOMSIZE, - FLUID_REVERB_DEFAULT_DAMP, - FLUID_REVERB_DEFAULT_WIDTH, - FLUID_REVERB_DEFAULT_LEVEL); + room, + damp, + width, + level); + } + + { + double level, speed, depth; + + fluid_settings_getint(settings, "synth.chorus.nr", &i); + fluid_settings_getnum(settings, "synth.chorus.level", &level); + fluid_settings_getnum(settings, "synth.chorus.speed", &speed); + fluid_settings_getnum(settings, "synth.chorus.depth", &depth); + + fluid_synth_set_chorus_full_LOCAL(synth, + FLUID_CHORUS_SET_ALL, + i, + level, + speed, + depth, + FLUID_CHORUS_DEFAULT_TYPE); + } /* Initialize multi-core variables if multiple cores enabled */ if (synth->cores > 1) @@ -3408,6 +3469,55 @@ fluid_synth_render_blocks(fluid_synth_t* synth, int blockcount) return blockcount; } +/* + * Handler for synth.reverb.* and synth.chorus.* double settings. + */ +static void fluid_synth_handle_reverb_chorus_num (void *data, const char *name, double value) +{ + fluid_synth_t *synth = (fluid_synth_t *)data; + fluid_return_if_fail(synth != NULL); + + if (FLUID_STRCMP(name, "synth.reverb.room-size") == 0) { + fluid_synth_set_reverb_roomsize(synth, value); + } + else if (FLUID_STRCMP(name, "synth.reverb.damp") == 0) { + fluid_synth_set_reverb_damp(synth, value); + } + else if (FLUID_STRCMP(name, "synth.reverb.width") == 0) { + fluid_synth_set_reverb_width(synth, value); + } + else if (FLUID_STRCMP(name, "synth.reverb.level") == 0) { + fluid_synth_set_reverb_level(synth, value); + } + else if (FLUID_STRCMP(name, "synth.chorus.depth") == 0) { + fluid_synth_set_chorus_depth(synth, value); + } + else if (FLUID_STRCMP(name, "synth.chorus.speed") == 0) { + fluid_synth_set_chorus_speed(synth, value); + } + else if (FLUID_STRCMP(name, "synth.chorus.level") == 0) { + fluid_synth_set_chorus_level(synth, value); + } +} + +/* + * Handler for synth.reverb.* and synth.chorus.* integer settings. + */ +static void fluid_synth_handle_reverb_chorus_int (void *data, const char *name, int value) +{ + fluid_synth_t *synth = (fluid_synth_t *)data; + fluid_return_if_fail(synth != NULL); + + if (FLUID_STRCMP(name, "synth.reverb.active") == 0) { + fluid_synth_set_reverb_on(synth, value); + } + else if (FLUID_STRCMP(name, "synth.chorus.active") == 0) { + fluid_synth_set_chorus_on(synth, value); + } + else if (FLUID_STRCMP(name, "synth.chorus.nr") == 0) { + fluid_synth_set_chorus_nr(synth, value); + } +} /* * Handler for synth.overflow.* settings. @@ -4408,7 +4518,6 @@ fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level, double speed, double depth_ms, int type) { int ret; - fluid_rvoice_param_t param[MAX_EVENT_PARAMS]; fluid_return_val_if_fail (synth != NULL, FLUID_FAILED); /* if non of the flags is set, fail */ @@ -4417,6 +4526,18 @@ fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level, /* Synth shadow values are set here so that they will be returned if queried */ fluid_synth_api_enter(synth); + ret = fluid_synth_set_chorus_full_LOCAL(synth, set, nr, level, speed, depth_ms, type); + + FLUID_API_RETURN(ret); +} + +static int +fluid_synth_set_chorus_full_LOCAL(fluid_synth_t* synth, int set, int nr, double level, + double speed, double depth_ms, int type) +{ + int ret; + fluid_rvoice_param_t param[MAX_EVENT_PARAMS]; + if (set & FLUID_CHORUS_SET_NR) synth->chorus_nr = nr; @@ -4443,7 +4564,7 @@ fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level, synth->eventhandler->mixer, param); - FLUID_API_RETURN(ret); + return (ret); } /** @@ -4484,7 +4605,7 @@ fluid_synth_get_chorus_level(fluid_synth_t* synth) * @return Chorus speed in Hz (0.29-5.0) */ double -fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth) +fluid_synth_get_chorus_speed(fluid_synth_t* synth) { double result; fluid_return_val_if_fail (synth != NULL, 0.0); @@ -4500,7 +4621,7 @@ fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth) * @return Chorus depth */ double -fluid_synth_get_chorus_depth_ms(fluid_synth_t* synth) +fluid_synth_get_chorus_depth(fluid_synth_t* synth) { double result; fluid_return_val_if_fail (synth != NULL, 0.0); diff --git a/src/synth/fluid_synth.h b/src/synth/fluid_synth.h index 2b2d9b31..30ebb4b1 100644 --- a/src/synth/fluid_synth.h +++ b/src/synth/fluid_synth.h @@ -46,6 +46,17 @@ #define FLUID_UNSET_PROGRAM 128 /* Program number used to unset a preset */ +#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f /**< Default reverb room size */ +#define FLUID_REVERB_DEFAULT_DAMP 0.0f /**< Default reverb damping */ +#define FLUID_REVERB_DEFAULT_WIDTH 0.5f /**< Default reverb width */ +#define FLUID_REVERB_DEFAULT_LEVEL 0.9f /**< Default reverb level */ + +#define FLUID_CHORUS_DEFAULT_N 3 /**< Default chorus voice count */ +#define FLUID_CHORUS_DEFAULT_LEVEL 2.0f /**< Default chorus level */ +#define FLUID_CHORUS_DEFAULT_SPEED 0.3f /**< Default chorus speed */ +#define FLUID_CHORUS_DEFAULT_DEPTH 8.0f /**< Default chorus depth */ +#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE /**< Default chorus waveform type */ + /*************************************************************** * * ENUM diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 77cf4a37..dd19372c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,6 +15,7 @@ ADD_FLUID_TEST(test_sample_rate_change) ADD_FLUID_TEST(test_preset_sample_loading) ADD_FLUID_TEST(test_pointer_alignment) ADD_FLUID_TEST(test_seqbind_unregister) +ADD_FLUID_TEST(test_synth_chorus_reverb) ADD_FLUID_TEST(test_snprintf) if ( LIBSNDFILE_HASVORBIS ) diff --git a/test/test_synth_chorus_reverb.c b/test/test_synth_chorus_reverb.c new file mode 100644 index 00000000..ac2c0baa --- /dev/null +++ b/test/test_synth_chorus_reverb.c @@ -0,0 +1,62 @@ + +#include "test.h" +#include "fluidsynth.h" + +// this test should make sure that sample rate changed are handled correctly +int main(void) +{ + fluid_synth_t *synth; + fluid_settings_t *settings = new_fluid_settings(); + TEST_ASSERT(settings != NULL); + + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.room-size", 0.1)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.damp", 0.2)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.width", 0.3)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.level", 0.4)); + + TEST_SUCCESS(fluid_settings_setint(settings, "synth.chorus.nr", 99)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.level", 0.5)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.speed", 0.6)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.depth", 0.7)); + + synth = new_fluid_synth(settings); + TEST_ASSERT(synth != NULL); + + // check that the synth is initialized with the correct values + TEST_ASSERT(fluid_synth_get_reverb_roomsize(synth) == 0.1); + TEST_ASSERT(fluid_synth_get_reverb_damp(synth) == 0.2); + TEST_ASSERT(fluid_synth_get_reverb_width(synth) == 0.3); + TEST_ASSERT(fluid_synth_get_reverb_level(synth) == 0.4); + + TEST_ASSERT(fluid_synth_get_chorus_nr(synth) == 99); + TEST_ASSERT(fluid_synth_get_chorus_level(synth) == 0.5); + TEST_ASSERT(fluid_synth_get_chorus_speed(synth) == 0.6); + TEST_ASSERT(fluid_synth_get_chorus_depth(synth) == 0.7); + + // update the realtime settings afterward + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.room-size", 0.11)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.damp", 0.22)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.width", 0.33)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.level", 0.44)); + + TEST_SUCCESS(fluid_settings_setint(settings, "synth.chorus.nr", 11)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.level", 0.55)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.speed", 0.66)); + TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.depth", 0.77)); + + // check that the realtime settings correctly update the values in the synth + TEST_ASSERT(fluid_synth_get_reverb_roomsize(synth) == 0.11); + TEST_ASSERT(fluid_synth_get_reverb_damp(synth) == 0.22); + TEST_ASSERT(fluid_synth_get_reverb_width(synth) == 0.33); + TEST_ASSERT(fluid_synth_get_reverb_level(synth) == 0.44); + + TEST_ASSERT(fluid_synth_get_chorus_nr(synth) == 11); + TEST_ASSERT(fluid_synth_get_chorus_level(synth) == 0.55); + TEST_ASSERT(fluid_synth_get_chorus_speed(synth) == 0.66); + TEST_ASSERT(fluid_synth_get_chorus_depth(synth) == 0.77); + + delete_fluid_synth(synth); + delete_fluid_settings(settings); + + return EXIT_SUCCESS; +}