101 |
if (!Decay1StepsLeft) Stage = (InfiniteSustain) ? stage_sustain : stage_decay2; |
if (!Decay1StepsLeft) Stage = (InfiniteSustain) ? stage_sustain : stage_decay2; |
102 |
} |
} |
103 |
while (iSample < process_end) { |
while (iSample < process_end) { |
104 |
Level += Decay1Coeff; |
Level += Level * Decay1Coeff; |
105 |
ModulationSystem::pDestinationParameter[ModulationSystem::destination_vca][iSample++] *= Level; |
ModulationSystem::pDestinationParameter[ModulationSystem::destination_vca][iSample++] *= Level; |
106 |
} |
} |
107 |
break; |
break; |
194 |
AttackCoeff = 0.0; |
AttackCoeff = 0.0; |
195 |
} |
} |
196 |
|
|
197 |
// calculate decay1 stage parameters (lin. curve) |
// calculate decay1 stage parameters (exp. curve) |
198 |
Decay1StepsLeft = (long) (Decay1Time * ModulationSystem::SampleRate()); |
Decay1StepsLeft = (long) (Decay1Time * ModulationSystem::SampleRate()); |
199 |
Decay1Coeff = (Decay1StepsLeft) ? (this->SustainLevel - 1.0) / Decay1StepsLeft : 0.0; |
Decay1Coeff = (Decay1StepsLeft) ? exp(log(this->SustainLevel) / (double) Decay1StepsLeft) - 1.0 |
200 |
|
: 0.0; |
201 |
|
|
202 |
// calculate decay2 stage parameters (exp. curve) |
// calculate decay2 stage parameters (exp. curve) |
203 |
if (!InfiniteSustain) { |
if (!InfiniteSustain) { |
210 |
// calcuate release stage parameters (exp. curve) |
// calcuate release stage parameters (exp. curve) |
211 |
if (ReleaseTime < EG_MIN_RELEASE_TIME) ReleaseTime = EG_MIN_RELEASE_TIME; // to avoid click sounds at the end of the sample playback |
if (ReleaseTime < EG_MIN_RELEASE_TIME) ReleaseTime = EG_MIN_RELEASE_TIME; // to avoid click sounds at the end of the sample playback |
212 |
ReleaseStepsLeft = (long) (ReleaseTime * ModulationSystem::SampleRate()); |
ReleaseStepsLeft = (long) (ReleaseTime * ModulationSystem::SampleRate()); |
|
//ReleaseCoeff = exp(log(EG_ENVELOPE_LIMIT) / (double) ReleaseStepsLeft) - 1.0; // <- this is only accurate for a curve start level of exactly 1.0, otherwise we have to use the following calculation for the coefficient... |
|
213 |
ReleaseCoeff = exp((log(EG_ENVELOPE_LIMIT) - log(this->SustainLevel)) / ReleaseStepsLeft + log(this->SustainLevel)) - this->SustainLevel; |
ReleaseCoeff = exp((log(EG_ENVELOPE_LIMIT) - log(this->SustainLevel)) / ReleaseStepsLeft + log(this->SustainLevel)) - this->SustainLevel; |
214 |
|
|
215 |
dmsg(4,("PreAttack=%d, AttackLength=%d, AttackCoeff=%f, Decay1Coeff=%f, Decay2Coeff=%f, ReleaseLength=%d, ReleaseCoeff=%f\n", |
dmsg(4,("PreAttack=%d, AttackLength=%d, AttackCoeff=%f, Decay1Coeff=%f, Decay2Coeff=%f, ReleaseLength=%d, ReleaseCoeff=%f\n", |