/[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 2174 by persson, Thu Aug 12 15:36:15 2010 UTC revision 2175 by persson, Mon Apr 25 08:12:36 2011 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 - 2010 Christian Schoenebeck and Grigor Iliev      *   *   Copyright (C) 2009 - 2011 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 93  namespace LinuxSampler { namespace sfz { Line 93  namespace LinuxSampler { namespace sfz {
93    
94          ri.EG3Attack     = pRegion->pitcheg_attack;          ri.EG3Attack     = pRegion->pitcheg_attack;
95          ri.EG3Depth      = 0; // TODO:          ri.EG3Depth      = 0; // TODO:
96          ri.VCFEnabled    = false; // TODO:          ri.VCFEnabled    = pRegion->cutoff;
97          ri.VCFType       = ::gig::vcf_type_lowpass; // TODO:          switch (pRegion->fil_type) {
98          ri.VCFResonance  = 0; // TODO:          case ::sfz::LPF_1P:
99                ri.VCFType = Filter::vcf_type_1p_lowpass;
100                break;
101            case ::sfz::LPF_2P:
102                ri.VCFType = Filter::vcf_type_2p_lowpass;
103                break;
104            case ::sfz::LPF_4P:
105                ri.VCFType = Filter::vcf_type_4p_lowpass;
106                break;
107            case ::sfz::LPF_6P:
108                ri.VCFType = Filter::vcf_type_6p_lowpass;
109                break;
110            case ::sfz::HPF_1P:
111                ri.VCFType = Filter::vcf_type_1p_highpass;
112                break;
113            case ::sfz::HPF_2P:
114                ri.VCFType = Filter::vcf_type_2p_highpass;
115                break;
116            case ::sfz::HPF_4P:
117                ri.VCFType = Filter::vcf_type_4p_highpass;
118                break;
119            case ::sfz::HPF_6P:
120                ri.VCFType = Filter::vcf_type_6p_highpass;
121                break;
122            case ::sfz::BPF_1P:
123            case ::sfz::BPF_2P:
124                ri.VCFType = Filter::vcf_type_2p_bandpass;
125                break;
126            case ::sfz::BRF_1P:
127            case ::sfz::BRF_2P:
128                ri.VCFType = Filter::vcf_type_2p_bandreject;
129                break;
130            case ::sfz::APF_1P:
131            case ::sfz::PKF_2P:
132            default:
133                ri.VCFEnabled = false;
134                break;
135            }
136    
137            ri.VCFResonance  = pRegion->resonance;
138    
139          // rt_decay is in dB. Precalculate a suitable value for exp in          // rt_decay is in dB. Precalculate a suitable value for exp in
140          // GetReleaseTriggerAttenuation: -ln(10) / 20 * rt_decay          // GetReleaseTriggerAttenuation: -ln(10) / 20 * rt_decay
# Line 134  namespace LinuxSampler { namespace sfz { Line 173  namespace LinuxSampler { namespace sfz {
173      }      }
174    
175      void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) {      void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) {
176          /*int ccvalue = itEvent->Param.CC.Value;          int ccvalue = itEvent->Param.CC.Value;
177          if (VCFCutoffCtrl.value == ccvalue) return;          if (VCFCutoffCtrl.value == ccvalue) return;
178          VCFCutoffCtrl.value == ccvalue;          VCFCutoffCtrl.value = ccvalue;
179          if (pRegion->VCFCutoffControllerInvert)  ccvalue = 127 - ccvalue;  
180          if (ccvalue < pRegion->VCFVelocityScale) ccvalue = pRegion->VCFVelocityScale;          float cutoff = CutoffBase * RTMath::CentsToFreqRatioUnlimited(
181          float cutoff = CutoffBase * float(ccvalue);              ccvalue / 127.0f * pRegion->cutoff_oncc[VCFCutoffCtrl.controller]);
182          if (cutoff > 127.0f) cutoff = 127.0f;          if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate;
183    
184          VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time          VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time
185          fFinalCutoff = cutoff;*/ // TODO: ^^^          fFinalCutoff = cutoff;
186      }      }
187    
188      double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) {      double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) {
# Line 267  namespace LinuxSampler { namespace sfz { Line 306  namespace LinuxSampler { namespace sfz {
306          return eg;          return eg;
307      }      }
308    
309        void Voice::TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {
310    
311            // TODO: the sfz filter EG should modulate cents, not hertz,
312            // so we can't use the EG or EGADSR as it is. Disable for now.
313    
314            pEG2 = &EGADSR2;
315            EGADSR2.trigger(0,
316                            0,
317                            false,
318                            0,
319                            1000,
320                            0,
321                            sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
322        }
323    
324      void Voice::InitLFO1() {      void Voice::InitLFO1() {
325          /*uint16_t lfo1_internal_depth;          /*uint16_t lfo1_internal_depth;
326          switch (pRegion->LFO1Controller) {          switch (pRegion->LFO1Controller) {
# Line 403  namespace LinuxSampler { namespace sfz { Line 457  namespace LinuxSampler { namespace sfz {
457      }      }
458    
459      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {
460          /*float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity);          float cutoff = *pRegion->cutoff;
461          if (pRegion->VCFKeyboardTracking) {          cutoff *= RTMath::CentsToFreqRatioUnlimited(
462              cutoff *= exp((MIDIKeyVelocity - pRegion->VCFKeyboardTrackingBreakpoint) * 0.057762265f); // (ln(2) / 12)              MIDIKeyVelocity / 127.0f * pRegion->fil_veltrack +
463          }              (MIDIKey - pRegion->fil_keycenter) * pRegion->fil_keytrack);
464          return cutoff;*/ // TODO: ^^^          return cutoff;
         return 1.0f;  
465      }      }
466    
467      float Voice::CalculateFinalCutoff(float cutoffBase) {      float Voice::CalculateFinalCutoff(float cutoffBase) {
468          /*int cvalue;          float cutoff;
469          if (VCFCutoffCtrl.controller) {          if (VCFCutoffCtrl.controller) {
470              cvalue = GetSfzEngineChannel()->ControllerTable[VCFCutoffCtrl.controller];              int ccvalue = GetSfzEngineChannel()->ControllerTable[VCFCutoffCtrl.controller];
471              if (pRegion->VCFCutoffControllerInvert) cvalue = 127 - cvalue;              cutoff = CutoffBase * RTMath::CentsToFreqRatioUnlimited(
472              // VCFVelocityScale in this case means Minimum cutoff                  ccvalue / 127.0f * pRegion->cutoff_oncc[VCFCutoffCtrl.controller]);
473              if (cvalue < pRegion->VCFVelocityScale) cvalue = pRegion->VCFVelocityScale;          } else {
474                cutoff = cutoffBase;
475          }          }
476          else {          if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate;
477              cvalue = pRegion->VCFCutoff;          return cutoff;
         }  
         float fco = cutoffBase * float(cvalue);  
         if (fco > 127.0f) fco = 127.0f;  
   
         return fco;*/ // TODO: ^^^  
         return 127.0f;  
478      }      }
479    
480      uint8_t Voice::GetVCFCutoffCtrl() {      uint8_t Voice::GetVCFCutoffCtrl() {
481          /*uint8_t ctrl;          // TODO: the sfz format allows several CC for the same
482          switch (pRegion->VCFCutoffController) {          // modulation destination. The Voice interface needs to be
483              case ::gig::vcf_cutoff_ctrl_modwheel:          // changed to support that.
484                  ctrl = 1;          if (pRegion->cutoff_cc) return pRegion->cutoff_cc;
485                  break;          else if (pRegion->cutoff_chanaft) return 128;
             case ::gig::vcf_cutoff_ctrl_effect1:  
                 ctrl = 12;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_effect2:  
                 ctrl = 13;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_breath:  
                 ctrl = 2;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_foot:  
                 ctrl = 4;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_sustainpedal:  
                 ctrl = 64;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_softpedal:  
                 ctrl = 67;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_genpurpose7:  
                 ctrl = 82;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_genpurpose8:  
                 ctrl = 83;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_aftertouch:  
                 ctrl = 128;  
                 break;  
             case ::gig::vcf_cutoff_ctrl_none:  
             default:  
                 ctrl = 0;  
                 break;  
         }  
   
         return ctrl;*/ // TODO: ^^^  
486          return 0;          return 0;
487      }      }
488    

Legend:
Removed from v.2174  
changed lines
  Added in v.2175

  ViewVC Help
Powered by ViewVC