/[svn]/linuxsampler/trunk/src/engines/gig/EGADSR.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/EGADSR.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 271 by schoenebeck, Fri Oct 8 20:51:39 2004 UTC revision 285 by schoenebeck, Thu Oct 14 21:31:26 2004 UTC
# Line 29  namespace LinuxSampler { namespace gig { Line 29  namespace LinuxSampler { namespace gig {
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) {
# Line 58  namespace LinuxSampler { namespace gig { Line 58  namespace LinuxSampler { namespace gig {
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) {
# Line 170  namespace LinuxSampler { namespace gig { Line 170  namespace LinuxSampler { namespace gig {
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) {
# Line 180  namespace LinuxSampler { namespace gig { Line 181  namespace LinuxSampler { namespace gig {
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      /**      /**

Legend:
Removed from v.271  
changed lines
  Added in v.285

  ViewVC Help
Powered by ViewVC