engine: fix bug in audio sustain
In some cases the ADSR might never decay fully to 0.
* If sustain volume is 0, proceed right from decay -> off
* Clamp ADSR to sustain volume when sustain phase is triggered
@@ -104,10 +104,15 @@ namespace blit {
adsr_step = (int32_t(sustain << 8) - int32_t(adsr)) / int32_t(adsr_end_frame);
}
void trigger_sustain() {
+ if(sustain == 0) {
+ off();
+ return;
+ }
adsr_frame = 0;
adsr_phase = ADSRPhase::SUSTAIN;
adsr_end_frame = 0;
adsr_step = 0;
+ adsr = int32_t(sustain << 8);
}
void trigger_release() {
adsr_frame = 0;
