/[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 2054 by persson, Wed Jun 3 17:21:42 2009 UTC revision 2055 by persson, Sat Jan 30 10:30:02 2010 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2009 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2010 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 27  Line 27 
27    
28  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
29    
     EGADSR::EGADSR() {  
         enterEndStage();  
         Level = 0.0;  
         CalculateFadeOutCoeff(CONFIG_EG_MIN_RELEASE_TIME, 44100.0); // even if the sample rate will be 192kHz it won't hurt at all  
     }  
   
     void EGADSR::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) {  
         const float killSteps = FadeOutTime * SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;  
         FadeOutCoeff = -1.0f / killSteps;  
     }  
   
30      void EGADSR::update(event_t Event, uint SampleRate) {      void EGADSR::update(event_t Event, uint SampleRate) {
31            if (atEnd(Event)) return;
32    
33          if (Event == event_hold_end) HoldAttack = false;          if (Event == event_hold_end) HoldAttack = false;
34    
35          switch (Stage) {          switch (Stage) {
# Line 149  namespace LinuxSampler { namespace gig { Line 140  namespace LinuxSampler { namespace gig {
140                          break;                          break;
141                  }                  }
142                  break;                  break;
             case stage_fadeout:  
                 switch (Event) {  
                     case event_stage_end:  
                         enterEndStage();  
                         break;  
                 }  
                 break;  
143          }          }
144      }      }
145    
# Line 180  namespace LinuxSampler { namespace gig { Line 164  namespace LinuxSampler { namespace gig {
164          ReleaseCoeff3 = ExpOffset * (1 - ReleaseCoeff2);          ReleaseCoeff3 = ExpOffset * (1 - ReleaseCoeff2);
165          ReleaseLevel2 = 0.25 * invVolume;          ReleaseLevel2 = 0.25 * invVolume;
166    
167            enterFirstStage();
168          enterAttackStage(PreAttack, AttackTime, SampleRate);          enterAttackStage(PreAttack, AttackTime, SampleRate);
169      }      }
170    
# Line 284  namespace LinuxSampler { namespace gig { Line 269  namespace LinuxSampler { namespace gig {
269          if (StepsLeft <= 0) enterFadeOutStage();          if (StepsLeft <= 0) enterFadeOutStage();
270      }      }
271    
     void EGADSR::enterFadeOutStage() {  
         Stage     = stage_fadeout;  
         Segment   = segment_lin;  
         StepsLeft = int(Level / (-FadeOutCoeff));  
         Coeff     = FadeOutCoeff;  
         if (StepsLeft <= 0) enterEndStage();  
     }  
   
     void EGADSR::enterFadeOutStage(int maxFadeOutSteps) {  
         Stage     = stage_fadeout;  
         Segment   = segment_lin;  
         StepsLeft = int(Level / (-FadeOutCoeff));  
         if (StepsLeft > maxFadeOutSteps) {  
             StepsLeft = maxFadeOutSteps;  
             Coeff = -Level / maxFadeOutSteps;  
         } else {  
             Coeff = FadeOutCoeff;  
         }  
         if (StepsLeft <= 0) enterEndStage();  
     }  
   
     void EGADSR::enterEndStage() {  
         Stage   = stage_end;  
         Segment = segment_end;  
         Level   = 0;  
     }  
   
272  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.2054  
changed lines
  Added in v.2055

  ViewVC Help
Powered by ViewVC