Word is many SoundFont implementations (e.g. FluidSynth) use a scale of 1 dB per 25 ticks for the initialAttenuation generator, in imitation of Creative/E-mu's original implementation. This contradicts the SoundFont spec, which specifies centibels: 1 dB per 10 ticks.
This PR just adds a special unit type, IPATCH_UNIT_TYPE_SF2_ATTENUATION, specific for the initialAttenuation generator. Goal is to make the "instrumentAtten" instrument in this SoundFont show up in the Swami UI with a 2 dB difference for Envelopes -> Attenuation between each note, instead of the 5 dB difference it currently shows.
Audio output in Swami still uses centibels. This fixes that:
diff --git a/src/plugins/fluidsynth.c b/src/plugins/fluidsynth.c
index 1442bc6..2d46c25 100644
--- a/src/plugins/fluidsynth.c
+++ b/src/plugins/fluidsynth.c
@@ -2404,7 +2404,10 @@ cache_instrument_noteon(WavetblFluidSynth *wavetbl, IpatchItem *item,
for(i = 0; i < IPATCH_SF2_GEN_COUNT; i++)
if(IPATCH_SF2_GEN_ARRAY_TEST_FLAG(gen_array, i))
{
- fluid_voice_gen_set(flvoice, i, (float)(gen_array->values[i].sword));
+ float val = (float)(gen_array->values[i].sword);
+ if(i == GEN_ATTENUATION)
+ val *= 0.4;
+ fluid_voice_gen_set(flvoice, i, val);
}
/* set modulators in fvoice internal list */
...But I kind of suspect there's better ways to handle it.
Word is many SoundFont implementations (e.g. FluidSynth) use a scale of 1 dB per 25 ticks for the
initialAttenuation
generator, in imitation of Creative/E-mu's original implementation. This contradicts the SoundFont spec, which specifies centibels: 1 dB per 10 ticks.This PR just adds a special unit type,
IPATCH_UNIT_TYPE_SF2_ATTENUATION
, specific for theinitialAttenuation
generator. Goal is to make the "instrumentAtten" instrument in this SoundFont show up in the Swami UI with a 2 dB difference for Envelopes -> Attenuation between each note, instead of the 5 dB difference it currently shows.Audio output in Swami still uses centibels. This fixes that:
...But I kind of suspect there's better ways to handle it.