envelope updates

Changed function to functional so max doesn't get cornfused. Added gate
indicator to AHR/AR/ASR.