97 auto const attack =
static_cast<audio_sample_count>(envelope().attack * sample_rate());
99 return mix(0.0f, amplitude(),
static_cast<float>(aIndex) / attack);
104 return mix(amplitude(), amplitude() * envelope().sustain,
static_cast<float>(aIndex) / decay);
107 auto const release =
static_cast<audio_sample_count>(envelope().release * sample_rate());
108 if (aIndex < aLength - release)
109 return amplitude() * envelope().sustain;
110 aIndex -= (aLength - release);
111 aLength -= (aLength - release);
112 if (aIndex < release)
113 return mix(amplitude() * envelope().sustain, 0.0f,
static_cast<float>(aIndex) / release);