mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Recalculate the release rate of the ADSR envelope if it was modified in ADSR::noteOff()
This commit is contained in:
parent
3c0ccda6a5
commit
97265bbd4f
1 changed files with 11 additions and 5 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue