200 |
void EGADSR::enterAttackStage(const uint PreAttack, const float AttackTime, const uint SampleRate) { |
void EGADSR::enterAttackStage(const uint PreAttack, const float AttackTime, const uint SampleRate) { |
201 |
Stage = stage_attack; |
Stage = stage_attack; |
202 |
Segment = segment_lin; |
Segment = segment_lin; |
203 |
// Measurements of GSt output shows that the real attack time |
|
204 |
// is about 65.5% of the value specified in the gig file. |
if (AttackTime >= 0.0005f) { |
205 |
StepsLeft = (int) (0.655f * AttackTime * SampleRate); |
// Measurements of GSt output shows that the real attack time |
206 |
if (StepsLeft) { |
// is about 65.5% of the value specified in the gig file. |
207 |
|
// The minimum attack value used is 0.032. |
208 |
|
StepsLeft = int(0.655f * RTMath::Max(AttackTime, 0.032f) * SampleRate); |
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 { // immediately jump to the next stage |
} else { // attack is zero - immediately jump to the next stage |
212 |
Level = 1.0; |
Level = 1.0; |
213 |
if (HoldAttack) enterAttackHoldStage(); |
if (HoldAttack) enterAttackHoldStage(); |
214 |
else enterDecay1Part1Stage(SampleRate); |
else enterDecay1Part1Stage(SampleRate); |