29 |
float EGADSR::CalculateFadeOutCoeff() { |
float EGADSR::CalculateFadeOutCoeff() { |
30 |
const float sampleRate = 44100.0; // even if the sample rate will be 192kHz it won't hurt at all |
const float sampleRate = 44100.0; // even if the sample rate will be 192kHz it won't hurt at all |
31 |
const float killSteps = EG_MIN_RELEASE_TIME * sampleRate; |
const float killSteps = EG_MIN_RELEASE_TIME * sampleRate; |
32 |
return 1.0f / killSteps; |
return -1.0f / killSteps; |
33 |
} |
} |
34 |
|
|
35 |
EGADSR::EGADSR(gig::Engine* pEngine, Event::destination_t ModulationDestination) { |
EGADSR::EGADSR(gig::Engine* pEngine, Event::destination_t ModulationDestination) { |
58 |
RTList<Event>::Iterator itTransitionEvent = (itTriggerEvent) ? ++itTriggerEvent : pEvents->first(); |
RTList<Event>::Iterator itTransitionEvent = (itTriggerEvent) ? ++itTriggerEvent : pEvents->first(); |
59 |
|
|
60 |
// if the voice was killed in this fragment we only process the time before this kill event, then switch to 'stage_fadeout' |
// if the voice was killed in this fragment we only process the time before this kill event, then switch to 'stage_fadeout' |
61 |
int Samples = (itKillEvent) ? itKillEvent->FragmentPos() : (int) TotalSamples; |
int Samples = (itKillEvent) ? RTMath::Min(itKillEvent->FragmentPos(), pEngine->MaxFadeOutPos) : (int) TotalSamples; |
62 |
|
|
63 |
int iSample = TriggerDelay; |
int iSample = TriggerDelay; |
64 |
while (iSample < TotalSamples) { |
while (iSample < TotalSamples) { |
170 |
Level += FadeOutCoeff; |
Level += FadeOutCoeff; |
171 |
pEngine->pSynthesisParameters[ModulationDestination][iSample++] *= Level; |
pEngine->pSynthesisParameters[ModulationDestination][iSample++] *= Level; |
172 |
} |
} |
173 |
if (Level <= FadeOutCoeff) Stage = stage_end; |
Stage = stage_end; |
174 |
|
if (Level > -FadeOutCoeff) dmsg(1,("EGADSR: Warning, final fade out level too high, may result in click sound!\n")); |
175 |
} //Fall through here instead of breaking otherwise we can get back into stage_fadeout and loop forever! |
} //Fall through here instead of breaking otherwise we can get back into stage_fadeout and loop forever! |
176 |
case stage_end: { |
case stage_end: { |
177 |
while (iSample < TotalSamples) { |
while (iSample < TotalSamples) { |
181 |
} |
} |
182 |
} |
} |
183 |
} |
} |
184 |
|
|
185 |
|
if (itKillEvent && Stage != stage_end) { |
186 |
|
dmsg(1,("EGADSR: VOICE KILLING NOT COMPLETED !!!\n")); |
187 |
|
dmsg(1,("EGADSR: Stage=%d,iSample=%d,Samples=%d, TotalSamples=%d, MaxFadoutPos=%d\n",Stage,iSample,Samples,TotalSamples,pEngine->MaxFadeOutPos)); |
188 |
|
} |
189 |
} |
} |
190 |
|
|
191 |
/** |
/** |