/[svn]/linuxsampler/trunk/src/eg_vca.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/eg_vca.cpp

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

revision 37 by schoenebeck, Wed Mar 10 22:01:36 2004 UTC revision 38 by schoenebeck, Tue Mar 16 13:25:39 2004 UTC
# Line 101  void EG_VCA::Process(uint Samples, RTELi Line 101  void EG_VCA::Process(uint Samples, RTELi
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;
# Line 194  void EG_VCA::Trigger(uint PreAttack, dou Line 194  void EG_VCA::Trigger(uint PreAttack, dou
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) {
# Line 209  void EG_VCA::Trigger(uint PreAttack, dou Line 210  void EG_VCA::Trigger(uint PreAttack, dou
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",

Legend:
Removed from v.37  
changed lines
  Added in v.38

  ViewVC Help
Powered by ViewVC