From dd9802e265fc9e90f8bd7b2bc3a7160b69111508 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 7 May 2019 10:25:41 +0100 Subject: [PATCH] ADSR: Set the envelope value to 1 when calling noteOn() with an attack rate of 0 --- modules/juce_audio_basics/utilities/juce_ADSR.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_basics/utilities/juce_ADSR.h b/modules/juce_audio_basics/utilities/juce_ADSR.h index 2a0788b885..6de3e8dae1 100644 --- a/modules/juce_audio_basics/utilities/juce_ADSR.h +++ b/modules/juce_audio_basics/utilities/juce_ADSR.h @@ -113,9 +113,19 @@ public: /** Starts the attack phase of the envelope. */ void noteOn() { - if (attackRate > 0.0f) currentState = State::attack; - else if (decayRate > 0.0f) currentState = State::decay; - else currentState = State::sustain; + if (attackRate > 0.0f) + { + currentState = State::attack; + } + else if (decayRate > 0.0f) + { + envelopeVal = 1.0f; + currentState = State::decay; + } + else + { + currentState = State::sustain; + } } /** Starts the release phase of the envelope. */