[sdiy] software / firmware envelopes in C (or anything else)
brianw
brianw at audiobanshee.com
Fri Nov 7 00:33:55 CET 2025
I agree, Tom.
Velocity is instantaneous, at the time of the Note On event.
Aftertouch, whether monophonic or polyphonic, is potentially continuous while the Note is playing. The usefulness of envelopes is decreased by aftertouch, though, so it doesn't quite make sense to alter the envelope based on aftertouch.
However, with Legato playing, it does make sense to alter the Sustain level of the envelope with the new Velocity, even though it's a new Note On without a corresponding Note Off for the previous note (although Note Off can occur *after* the new Note On).
Brian
On Nov 6, 2025, at 2:13 PM, Tom Wiltshire <tom at electricdruid.net> wrote:
> Many thanks, Chris.
>
> Yes, multiplying the envelope output by velocity will cause an abrupt jump if the envelope isn't at zero. Running the attack to a new higher level is a a neater way of doing it, avoids the problem, and makes a lot of sense. I like it.
>
> "Velocity modulation" seems a bit weird to me since MIDI only deals with velocity at note on and note off. At other times, surely some other variable would make more sense? How can you change the velocity of a key press after it's occurred? It seems a bit meaningless. I can see that if "velocity" is simply some variable that is multiplied by the envelope output before it is used, you could modulate it as much as you like in your firmware, but physically, it stops making sense - furthermore it causes the problems you've identified.
>
> On 6 Nov 2025, at 18:38, Chris McDowell <declareupdate at gmail.com> wrote:
>> My use of the term "side effects" was sloppy, because I think there's only one and it is the primary effect. An envelope through a VCA can jump abruptly, where this one will only jump as abruptly as the envelope stage rates allow. It will only ever ramp toward new targets.
>>
>> If it's a monophonic implementation and in a legato mode with previous notes held, new notes cause the output to ramp toward the new sustain value at the rate of decay. In a non-legato mode, new notes cause the output to ramp toward velocity * 2.0 at the rate of attack.
>>
>> If it is a polyphonic synth, it only comes in to play when a voice is stolen. The volume or cutoff or whatever of that voice will ramp toward velocity * 2.0 from wherever it happens to be.
>>
>> I had thought for a bit that adding slew to a velocity signal controlling a VCA could be one solution, but what rate to choose for that slew is unclear and it interacts with the rest of the envelope output. I like the simplicity of my envelopes only ever operating via targets and rates.
>>
>> This is a limitation I don't love in the Prophet REV2, for example. It welcomes pretty flexible velocity modulation, but it is always an abrupt effect. I have not consciously encountered a velocity implementation like mine in the wild.
>>
>> Chris McDowell
>>
>> On Nov 6, 2025, at 8:11 AM, Tom Wiltshire <tom at electricdruid.net> wrote:
>>> On 6 Nov 2025, at 12:44, Chris McDowell via Synth-diy <synth-diy at synth-diy.org> wrote:
>>>> When velocity is involved, I set the attack target to 2 * velocity, and the sustain level to sustain * velocity, instead of multiplying the envelope output by velocity. this has some side effects but feels a lot more natural to me
>>>
>>> Interesting. What's the difference? At first glance, that sounds like it would be the same (at least for constant-time envelopes - I can see constant-rate envelopes would change).
More information about the Synth-diy
mailing list