/[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 286 by schoenebeck, Sat Oct 16 17:29:05 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    
65            #if DEVMODE
66            if (TriggerDelay > TotalSamples) { // FIXME: should be removed before the final release (purpose: just a sanity check for debugging)
67                dmsg(1,("EGADSR: ERROR, TriggerDelay > Totalsamples\n"));
68                int* i = NULL;
69                (*i)++; // force a segfault
70            }
71            #endif // DEVMODE
72    
73          while (iSample < TotalSamples) {          while (iSample < TotalSamples) {
74    
75              // if the voice was killed in this fragment and we already processed the time before this kill event              // if the voice was killed in this fragment and we already processed the time before this kill event
# Line 170  namespace LinuxSampler { namespace gig { Line 179  namespace LinuxSampler { namespace gig {
179                          Level += FadeOutCoeff;                          Level += FadeOutCoeff;
180                          pEngine->pSynthesisParameters[ModulationDestination][iSample++] *= Level;                          pEngine->pSynthesisParameters[ModulationDestination][iSample++] *= Level;
181                      }                      }
182                      if (Level <= FadeOutCoeff) Stage = stage_end;                      Stage = stage_end;
183                        if (Level > -FadeOutCoeff) dmsg(1,("EGADSR: Warning, final fade out level too high, may result in click sound!\n"));
184                  } //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!
185                  case stage_end: {                  case stage_end: {
186                      while (iSample < TotalSamples) {                      while (iSample < TotalSamples) {
# Line 180  namespace LinuxSampler { namespace gig { Line 190  namespace LinuxSampler { namespace gig {
190                  }                  }
191              }              }
192          }          }
193    
194            #if DEVMODE
195            if (itKillEvent && Stage != stage_end) { // FIXME: should be removed before the final release (purpose: just a sanity check for debugging)
196                dmsg(1,("EGADSR: ERROR, voice killing not completed !!!\n"));
197                dmsg(1,("EGADSR: Stage=%d,iSample=%d,Samples=%d, TotalSamples=%d, MaxFadoutPos=%d\n",Stage,iSample,Samples,TotalSamples,pEngine->MaxFadeOutPos));
198            }
199            #endif // DEVMODE
200      }      }
201    
202      /**      /**

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

  ViewVC Help
Powered by ViewVC