32 |
} |
} |
33 |
|
|
34 |
void EGADSR::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) { |
void EGADSR::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) { |
35 |
const float killSteps = FadeOutTime * SampleRate; |
const float killSteps = FadeOutTime * SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
36 |
FadeOutCoeff = -1.0f / killSteps; |
FadeOutCoeff = -1.0f / killSteps; |
37 |
} |
} |
38 |
|
|
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); |
286 |
Segment = segment_lin; |
Segment = segment_lin; |
287 |
StepsLeft = int((ReleaseLevel2 - Level) / ReleaseCoeff); |
StepsLeft = int((ReleaseLevel2 - Level) / ReleaseCoeff); |
288 |
Coeff = ReleaseCoeff; |
Coeff = ReleaseCoeff; |
289 |
|
if (StepsLeft == 0) enterReleasePart2Stage(); |
290 |
} |
} |
291 |
|
|
292 |
void EGADSR::enterReleasePart2Stage() { |
void EGADSR::enterReleasePart2Stage() { |
295 |
StepsLeft = int(log((CONFIG_EG_BOTTOM - ExpOffset) / (Level - ExpOffset)) / ReleaseSlope); |
StepsLeft = int(log((CONFIG_EG_BOTTOM - ExpOffset) / (Level - ExpOffset)) / ReleaseSlope); |
296 |
Coeff = ReleaseCoeff2; |
Coeff = ReleaseCoeff2; |
297 |
Offset = ReleaseCoeff3; |
Offset = ReleaseCoeff3; |
298 |
|
if (StepsLeft == 0) enterFadeOutStage(); |
299 |
} |
} |
300 |
|
|
301 |
void EGADSR::enterFadeOutStage() { |
void EGADSR::enterFadeOutStage() { |
309 |
void EGADSR::enterEndStage() { |
void EGADSR::enterEndStage() { |
310 |
Stage = stage_end; |
Stage = stage_end; |
311 |
Segment = segment_end; |
Segment = segment_end; |
312 |
|
Level = 0; |
313 |
} |
} |
314 |
|
|
315 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |