diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 1b963824..9e732d35 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -641,7 +641,6 @@ is one, midi driver is one, midi player is one etc) so you should usually leave it on. Also see synth.parallel-render. - synth.verbose Type @@ -660,6 +659,35 @@ leave it on. Also see synth.parallel-render. can be helpful for debugging. This setting cannot be changed after the synthesizer has started. + + + synth.volenv + Type + string + + + + Default + emu + + + + Options + compliant, emu + + + + Description + Specifies the kind of volume envelope processing. This + esp. influences the way fluidsynth responses to noteon velocity. + The default setting 'emu' causes the envelope to be highly + dynamic (i.e. compatible with the EMU10K1). Alternatively this + may be set to 'compliant' for a less dynamic envelope, as it was + done before fluidsynth 1.0.9. Note that this setting can only be + changed until the first synth has been created. Changing it + afterwards will have no effect for the rest of fluidsynths + lifetime. + \section CreatingAudioDriver Creating the Audio Driver diff --git a/doc/fluidsynth.1 b/doc/fluidsynth.1 index 5ca03981..4c5c838c 100644 --- a/doc/fluidsynth.1 +++ b/doc/fluidsynth.1 @@ -221,6 +221,9 @@ Must always to be true for usage by fluidsynth executable. .TP .B synth.verbose BOOL [def=False] Print received MIDI events to stdout. +.TP +.B synth.volenv STR [def='emu' vals:'compliant', 'emu'] +Specifies the kind of volume envelope processing. This esp. influences the way fluidsynth responses to noteon velocity. The default setting 'emu' causes the envelope to be highly dynamic (i.e. compatible with the EMU10K1). Alternatively this may be set to 'compliant' for a less dynamic envelope, as it was done before fluidsynth 1.0.9. .TP .B GENERAL AUDIO diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index bae876bb..6c94ad89 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -225,6 +225,9 @@ void fluid_synth_settings(fluid_settings_t* settings) fluid_settings_add_option(settings, "synth.midi-bank-select", "xg"); fluid_settings_add_option(settings, "synth.midi-bank-select", "mma"); + fluid_settings_register_str(settings, "synth.volenv", "emu", 0, NULL, NULL); + fluid_settings_add_option(settings, "synth.volenv", "emu"); + fluid_settings_add_option(settings, "synth.volenv", "compliant"); } /** @@ -555,8 +558,29 @@ new_fluid_synth(fluid_settings_t *settings) double gain; int i, nbuf; + /* initialize all the conversion tables and other stuff */ - if (fluid_synth_initialized == 0) { + if (fluid_synth_initialized == 0) + { + char buf[64]; + if (fluid_settings_str_equal (settings, "synth.volenv", "compliant") == FLUID_OK) + { + fluid_conversion_set_atten_power(FLUID_ATTEN_POWER_DEFAULT_COMPLIANT); + } + else if (fluid_settings_str_equal (settings, "synth.volenv", "emu") == FLUID_OK) + { + fluid_conversion_set_atten_power(FLUID_ATTEN_POWER_DEFAULT_EMU); + } + else + { + if (fluid_settings_copystr(settings, "synth.volenv", buf, sizeof(buf)/sizeof(buf[0])) == FLUID_OK) + { + double atten = atof(buf); + if(atten != 0.0) + fluid_conversion_set_atten_power(atten); + } + } + fluid_synth_init(); } diff --git a/src/utils/fluid_conv.c b/src/utils/fluid_conv.c index 50ab1010..13ea6b5e 100644 --- a/src/utils/fluid_conv.c +++ b/src/utils/fluid_conv.c @@ -21,6 +21,13 @@ #include "fluid_conv.h" +/* EMU 8k/10k don't follow spec in regards to volume attenuation. + * This factor is used in the equation pow (10.0, cb / FLUID_ATTEN_POWER_FACTOR). + * By the standard this should be -200.0. */ +/* 07/11/2008 modified by S. Christian Collins for increased velocity sensitivity. + * Now it equals the response of EMU10K1 programming.*/ +static double FLUID_ATTEN_POWER_FACTOR = FLUID_ATTEN_POWER_DEFAULT_EMU; /* was (-531.509)*/ + /* conversion tables */ fluid_real_t fluid_ct2hz_tab[FLUID_CENTS_HZ_SIZE]; fluid_real_t fluid_cb2amp_tab[FLUID_CB_AMP_SIZE]; @@ -91,6 +98,11 @@ fluid_conversion_config(void) } } +void fluid_conversion_set_atten_power(double atten) +{ + FLUID_ATTEN_POWER_FACTOR = atten; +} + /* * fluid_ct2hz */ diff --git a/src/utils/fluid_conv.h b/src/utils/fluid_conv.h index f0b91168..838b1496 100644 --- a/src/utils/fluid_conv.h +++ b/src/utils/fluid_conv.h @@ -29,13 +29,11 @@ #define FLUID_ATTEN_AMP_SIZE 1441 #define FLUID_PAN_SIZE 1002 -/* EMU 8k/10k don't follow spec in regards to volume attenuation. - * This factor is used in the equation pow (10.0, cb / FLUID_ATTEN_POWER_FACTOR). - * By the standard this should be -200.0. */ -/* 07/11/2008 modified by S. Christian Collins for increased velocity sensitivity. Now it equals the response of EMU10K1 programming.*/ -#define FLUID_ATTEN_POWER_FACTOR (-200.0) /* was (-531.509)*/ +#define FLUID_ATTEN_POWER_DEFAULT_EMU (-200.0) +#define FLUID_ATTEN_POWER_DEFAULT_COMPLIANT (-531.509) void fluid_conversion_config(void); +void fluid_conversion_set_atten_power(double atten); fluid_real_t fluid_ct2hz_real(fluid_real_t cents); fluid_real_t fluid_ct2hz(fluid_real_t cents);