/[svn]/linuxsampler/trunk/src/engines/sfz/Voice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/sfz/Voice.cpp

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

revision 2237 by iliev, Fri Aug 12 13:07:05 2011 UTC revision 2327 by persson, Sat Mar 10 16:16:14 2012 UTC
# Line 4  Line 4 
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 - 2008 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *
7   *   Copyright (C) 2009 - 2011 Christian Schoenebeck and Grigor Iliev      *   *   Copyright (C) 2009 - 2012 Christian Schoenebeck and Grigor Iliev      *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
10   *   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 34  namespace LinuxSampler { namespace sfz { Line 34  namespace LinuxSampler { namespace sfz {
34      typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoice;      typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoice;
35      Voice::Voice(): SignalRack(this), SfzVoice(&SignalRack) {      Voice::Voice(): SignalRack(this), SfzVoice(&SignalRack) {
36          pEngine     = NULL;          pEngine     = NULL;
37            bEqSupport = true;
38      }      }
39    
40      Voice::~Voice() {      Voice::~Voice() {
# Line 137  namespace LinuxSampler { namespace sfz { Line 138  namespace LinuxSampler { namespace sfz {
138      }      }
139    
140      double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) {      double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) {
141          return pRegion->amp_velcurve[MIDIKeyVelocity];          float offset = -pRegion->amp_veltrack;
142            if (offset <= 0) offset += 100;
143            return (offset + pRegion->amp_veltrack * pRegion->amp_velcurve[MIDIKeyVelocity]) / 100;
144      }      }
145    
146      double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) {      double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) {
# Line 153  namespace LinuxSampler { namespace sfz { Line 156  namespace LinuxSampler { namespace sfz {
156          }*/ // TODO: ^^^          }*/ // TODO: ^^^
157      }      }
158    
     void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) {  
         int ccvalue = itEvent->Param.CC.Value;  
         if (VCFCutoffCtrl.value == ccvalue) return;  
         VCFCutoffCtrl.value = ccvalue;  
   
         float cutoff = CutoffBase * RTMath::CentsToFreqRatioUnlimited(  
             ccvalue / 127.0f * pRegion->cutoff_oncc[VCFCutoffCtrl.controller]);  
         if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate;  
   
         VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time  
         fFinalCutoff = cutoff;  
     }  
   
159      double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) {      double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) {
160          /*float crossfadeVolume;          /*float crossfadeVolume;
161          switch (pRegion->AttenuationController.type) {          switch (pRegion->AttenuationController.type) {
# Line 271  namespace LinuxSampler { namespace sfz { Line 261  namespace LinuxSampler { namespace sfz {
261      }      }
262    
263      float Voice::CalculateFinalCutoff(float cutoffBase) {      float Voice::CalculateFinalCutoff(float cutoffBase) {
264          float cutoff;          float cutoff = cutoffBase;
         if (VCFCutoffCtrl.controller) {  
             int ccvalue = GetSfzEngineChannel()->ControllerTable[VCFCutoffCtrl.controller];  
             cutoff = CutoffBase * RTMath::CentsToFreqRatioUnlimited(  
                 ccvalue / 127.0f * pRegion->cutoff_oncc[VCFCutoffCtrl.controller]);  
         } else {  
             cutoff = cutoffBase;  
         }  
265          if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate;          if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate;
266          return cutoff;          return cutoff;
267      }      }
268    
     uint8_t Voice::GetVCFCutoffCtrl() {  
         // TODO: the sfz format allows several CC for the same  
         // modulation destination. The Voice interface needs to be  
         // changed to support that.  
         if (pRegion->cutoff_cc) return pRegion->cutoff_cc;  
         else if (pRegion->cutoff_chanaft) return 128;  
         return 0;  
     }  
   
     uint8_t Voice::GetVCFResonanceCtrl() {  
         /*uint8_t ctrl;  
         switch (pRegion->VCFResonanceController) {  
             case ::gig::vcf_res_ctrl_genpurpose3:  
                 ctrl = 18;  
                 break;  
             case ::gig::vcf_res_ctrl_genpurpose4:  
                 ctrl = 19;  
                 break;  
             case ::gig::vcf_res_ctrl_genpurpose5:  
                 ctrl = 80;  
                 break;  
             case ::gig::vcf_res_ctrl_genpurpose6:  
                 ctrl = 81;  
                 break;  
             case ::gig::vcf_res_ctrl_none:  
             default:  
                 ctrl = 0;  
         }  
   
         return ctrl;*/ // TODO: ^^^  
         return 0;  
     }  
   
269      float Voice::GetReleaseTriggerAttenuation(float noteLength) {      float Voice::GetReleaseTriggerAttenuation(float noteLength) {
270          // pow(10, -rt_decay * noteLength / 20):          // pow(10, -rt_decay * noteLength / 20):
271          return expf(RgnInfo.ReleaseTriggerDecay * noteLength);          return expf(RgnInfo.ReleaseTriggerDecay * noteLength);
# Line 348  namespace LinuxSampler { namespace sfz { Line 298  namespace LinuxSampler { namespace sfz {
298          }          }
299      }      }
300    
301        void Voice::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) {
302            SignalRack.CalculateFadeOutCoeff(FadeOutTime, SampleRate);
303        }
304    
305  }} // namespace LinuxSampler::sfz  }} // namespace LinuxSampler::sfz

Legend:
Removed from v.2237  
changed lines
  Added in v.2327

  ViewVC Help
Powered by ViewVC