Merge pull request #204 from FluidSynth/volenv

Add a setting for volume envelope processing
This commit is contained in:
Tom M 2017-09-21 15:08:27 +02:00 committed by GitHub
commit eba43faf6c
5 changed files with 72 additions and 7 deletions

View File

@ -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.</td>
</tr>
<tr>
<td>synth.verbose</td>
<td>Type</td>
@ -660,6 +659,35 @@ leave it on. Also see synth.parallel-render.</td>
can be helpful for debugging. This setting cannot be changed
after the synthesizer has started.</td>
</tr>
<tr>
<td>synth.volenv</td>
<td>Type</td>
<td>string</td>
</tr>
<tr>
<td></td>
<td>Default</td>
<td>emu</td>
</tr>
<tr>
<td></td>
<td>Options</td>
<td>compliant, emu</td>
</tr>
<tr>
<td></td>
<td>Description</td>
<td>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.</td>
</tr>
</table>
\section CreatingAudioDriver Creating the Audio Driver

View File

@ -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

View File

@ -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();
}

View File

@ -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
*/

View File

@ -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);