Here's an example of analog-style ADSR envelopes created in gen~. These are RC style (so convex going up, concave going down) and are the sum of an AD envelope and an ASR envelope. If you are interested in analog-style envelopes or slew limiters, there is some useful code that demonstrates how to calculate the attack and decay coefficients for slide.
They can respond to changes in parameters at signal rate and they (should) behave similar to analog envelopes in that they are constant rate rather than constant time. That means that the release time of the envelope may be different depending on where the envelope is when the release is triggered. There is also an attack lockout feature which prevents release/decay from occurring until the attack has finished; this is off by default.
The first one behaves like the Moog Mini (no retriggering while sustaining) and the second one behaves like the Arp 2600 (retriggering on every new note). These are not optimized, but they are functional and commented for learning purposes. I haven't included a reset from 0. capability in order to keep the code simpler, but it is certainly possible to implement this feature. Like analog envelopes, these envelopes are not velocity sensitive, though it is possible to modify them so that they are.
================== UPDATED VERSION POSTED IN COMMENT BELOW =================