Hello,
Please see below for an ADSR based on a lookup table. Advantages of this implementation are that it is extremely light-weight, has an exponential/differential profile and that the attack, decay and release times can be precisely controlled. The example provided with the class is optimized for the Arduino Due, but the class can be used by any other platform. The ADSR shape is based on the ADSR that m0xpd posted here sometime ago and so I thought I would share my version as well. Have fun!