Browse Source

Recalculate the release rate of the ADSR envelope if it was modified in ADSR::noteOff()

tags/2021-05-28
ed 6 years ago
parent
commit
7ffcd5e5f4
1 changed files with 11 additions and 5 deletions
  1. +11
    -5
      modules/juce_audio_basics/utilities/juce_ADSR.h

+ 11
- 5
modules/juce_audio_basics/utilities/juce_ADSR.h View File

@@ -102,6 +102,12 @@ public:
{
envelopeVal = 0.0f;
currentState = State::idle;
if (resetReleaseRate)
{
releaseRate = static_cast<float> (sustainLevel / (currentParameters.release * sr));
resetReleaseRate = false;
}
}
/** Starts the attack phase of the envelope. */
@@ -120,7 +126,10 @@ public:
if (releaseRate > 0.0f)
{
if (currentState != State::sustain)
{
releaseRate = static_cast<float> (envelopeVal / (currentParameters.release * sr));
resetReleaseRate = true;
}
currentState = State::release;
}
@@ -229,11 +238,8 @@ private:
Parameters currentParameters;
double sr = 0.0;
float envelopeVal = 0.0f;
float sustainLevel = 0.0f;
float attackRate = 0.0f, decayRate = 0.0f, releaseRate = 0.0f;
float envelopeVal = 0.0f, sustainLevel = 0.0f, attackRate = 0.0f, decayRate = 0.0f, releaseRate = 0.0f;
bool resetReleaseRate = false;
};
} // namespace juce

Loading…
Cancel
Save