Say you had a sample with a loud attack but a sustain that's quieter. Normally, you'd have to use automatic gain to level out the amplitude across the whole sample externally.
What if instead of changing the sample itself, the gain is changed before output?
Loud attack with quiet sustain + non-leveled sample = loud attack with no timbre
Loud attack with quiet sustain + adjusting the sample with external gain controls = some sounds that should be quieter are amplified along with the timbre you're trying to capture
My idea: The sample doesn't need to be modified, and the attack can stay as loud as it wants to because the sustain will be dynamically compensated using velocity as a function. It would even play nice with attenuation because the maximum loudness would be set, meaning instead of low velocity making the sustain quiet to the point of inaudible, you would have your full attack and the gain at a specific velocity would pull up the usually quiet sustain to audible levels.
When playing a sample, the evolution of the volume is made by the envelop volume that has different phases:
* delay: level is 0 for a specified duration (usually we don't want this so we go directly to the attack)
* attack: from 0 to the maximum level
* hold: the maximum level is kept for a specified duration
* decay: from the maximum level to the sustain level
* sustain: a pourcentage of the maximum level is kept as long the key is held
* release: from the sustain level to 0
Having this in mind I think you would like a sustain volume that is more than 100% of the maximum value reached by the attack and this is not possible with the current version of the sf2 format. The decay can only decrease the volume from a maximum to the sustain level that is from 0 to 100% only of the maximum volume.