I’m writing yet another sf2 importer, and I have time-based values for attack, decay, hold, and release for an AHDSR device. Only issue is… the parameter seems to be non-linear. Setting to 0 puts the value at 0, setting to 1 results in 60s, but setting to 0.5 results in… 7.500s?
Is there a way to set these to a specific number of seconds (or milliseconds)? If not, what mapping should I use to determine the value to set on these?
@jneen d’you mind if i take a look at your SF2 envelope code and try to see if i could learn from that and apply it to Paketti’s SF2 envelope code? (which is currently nonexistent)
Fun, I’m using Paketti as a bit of a reference since this is my first time making a Renoise tool! Right now I’ve got a basic use case working but a) there are plenty of parts of the spec I know I’m not implementing, and b) I’m currently making a separate modulation set for every sample, even if the parameters are all the same, which technically works but is not ideal.
The hardest part (which I’m still not completely sure I’ve got right) is the fact that (at least according to FluidSynth) attack seems to be linear in amplitude, but decay and release seem to be linear in dB - Renoise’s smoothing parameter can only approximate this behaviour, and calculating the optimal value for this is a lot of math.
There’s a couple of things that I think are not possible, such as the Delay parameter for AHDSR, which SoundFont specifies as an amount of time before the attack starts. This could be implemented with an Envelope device potentially, but Envelope works a bit differently than the spec - if key-off occurs before the end of decay in a short note for example, it seems to play out the whole decay curve before the release phase starts.
There’s also the matter of things like keynumToVolEnvDecay, which I don’t think can be done without a macro, and certainly won’t play nice with polyphony.