209 |
Level = (float) PreAttack / 1000.0; |
Level = (float) PreAttack / 1000.0; |
210 |
Coeff = 0.896f * (1.0f - Level) / StepsLeft; // max level is a bit lower if attack != 0 |
Coeff = 0.896f * (1.0f - Level) / StepsLeft; // max level is a bit lower if attack != 0 |
211 |
} else { // attack is zero - immediately jump to the next stage |
} else { // attack is zero - immediately jump to the next stage |
212 |
Level = 1.0; |
Level = 1.029f; // a bit higher than max sustain |
213 |
if (HoldAttack) enterAttackHoldStage(); |
if (HoldAttack) enterAttackHoldStage(); |
214 |
else enterDecay1Part1Stage(SampleRate); |
else enterDecay1Part1Stage(SampleRate); |
215 |
} |
} |
234 |
// (where d is 1/SampleRate). The transition from f to g is |
// (where d is 1/SampleRate). The transition from f to g is |
235 |
// done when f(x) has reached Level2 = 25% of full volume. |
// done when f(x) has reached Level2 = 25% of full volume. |
236 |
StepsLeft = (int) (Decay1Time * SampleRate); |
StepsLeft = (int) (Decay1Time * SampleRate); |
237 |
if (StepsLeft && SustainLevel < 1.0 && Level > SustainLevel) { |
if (StepsLeft && Level > SustainLevel) { |
238 |
Stage = stage_decay1_part1; |
Stage = stage_decay1_part1; |
239 |
Segment = segment_lin; |
Segment = segment_lin; |
240 |
Decay1Slope = 1.365 * (SustainLevel - 1.0) / StepsLeft; |
Decay1Slope = (1.347f * SustainLevel - 1.361f) / StepsLeft; |
241 |
Coeff = Decay1Slope * invVolume; |
Coeff = Decay1Slope * invVolume; |
242 |
Decay1Level2 = 0.25 * invVolume; |
Decay1Level2 = 0.25 * invVolume; |
243 |
if (Level < Decay1Level2) enterDecay1Part2Stage(SampleRate); |
if (Level < Decay1Level2) enterDecay1Part2Stage(SampleRate); |
265 |
void EGADSR::enterDecay2Stage(const uint SampleRate) { |
void EGADSR::enterDecay2Stage(const uint SampleRate) { |
266 |
Stage = stage_decay2; |
Stage = stage_decay2; |
267 |
Segment = segment_lin; |
Segment = segment_lin; |
268 |
Decay2Time = RTMath::Max(Decay2Time, CONFIG_EG_MIN_RELEASE_TIME); |
Decay2Time = RTMath::Max(Decay2Time, 0.05f); |
269 |
StepsLeft = (int) (Decay2Time * SampleRate); |
StepsLeft = (int) (Decay2Time * SampleRate); |
270 |
Coeff = (-1.03 / StepsLeft) * invVolume; |
Coeff = (-1.03 / StepsLeft) * invVolume; |
271 |
//FIXME: do we really have to calculate 'StepsLeft' two times? |
//FIXME: do we really have to calculate 'StepsLeft' two times? |