/[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 2218 by iliev, Thu Jul 28 08:05:57 2011 UTC revision 2224 by iliev, Mon Aug 1 19:08:09 2011 UTC
# Line 237  namespace LinuxSampler { namespace sfz { Line 237  namespace LinuxSampler { namespace sfz {
237          return eg;          return eg;
238      }      }
239    
     void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {  
   
         // TODO: controller modulation  
   
         // first check if there is a v2 EG for amplitude  
         for (int i = 0 ; i < pRegion->eg.size() ; i++) {  
             if (pRegion->eg[i].amplitude > 0) {  
                 // TODO: actually use the value of the amplitude parameter  
                 pEG1 = &EG1;  
                 EG1.trigger(pRegion->eg[i], sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE, velocity);  
                 return;  
             }  
         }  
   
         // otherwise use the v1 EGADSR  
         pEG1 = &EGADSR1;  
         EGADSR1.trigger(uint(pRegion->ampeg_start * 10),  
                         std::max(0.0, pRegion->ampeg_attack + pRegion->ampeg_vel2attack * velrelease),  
                         std::max(0.0, pRegion->ampeg_hold + pRegion->ampeg_vel2hold * velrelease),  
                         std::max(0.0, pRegion->ampeg_decay + pRegion->ampeg_vel2decay * velrelease),  
                         uint(std::min(std::max(0.0, 10 * (pRegion->ampeg_sustain + pRegion->ampeg_vel2sustain * velrelease)), 1000.0)),  
                         std::max(0.0, pRegion->ampeg_release + pRegion->ampeg_vel2release * velrelease),  
                         sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);  
     }  
   
240      double Voice::GetEG2ControllerValue(uint8_t MIDIKeyVelocity) {      double Voice::GetEG2ControllerValue(uint8_t MIDIKeyVelocity) {
241          /*double eg2controllervalue = 0;          /*double eg2controllervalue = 0;
242          switch (pRegion->EG2Controller.type) {          switch (pRegion->EG2Controller.type) {
# Line 298  namespace LinuxSampler { namespace sfz { Line 273  namespace LinuxSampler { namespace sfz {
273          return eg;          return eg;
274      }      }
275    
     void Voice::TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {  
   
         // TODO: the sfz filter EG should modulate cents, not hertz,  
         // so we can't use the EG or EGADSR as it is. Disable for now.  
   
         pEG2 = &EGADSR2;  
         EGADSR2.trigger(0,  
                         0,  
                         false,  
                         0,  
                         1000,  
                         0,  
                         sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);  
     }  
   
     void Voice::InitLFO1() {  
         /*uint16_t lfo1_internal_depth;  
         switch (pRegion->LFO1Controller) {  
             case ::gig::lfo1_ctrl_internal:  
                 lfo1_internal_depth  = pRegion->LFO1InternalDepth;  
                 pLFO1->ExtController = 0; // no external controller  
                 bLFO1Enabled         = (lfo1_internal_depth > 0);  
                 break;  
             case ::gig::lfo1_ctrl_modwheel:  
                 lfo1_internal_depth  = 0;  
                 pLFO1->ExtController = 1; // MIDI controller 1  
                 bLFO1Enabled         = (pRegion->LFO1ControlDepth > 0);  
                 break;  
             case ::gig::lfo1_ctrl_breath:  
                 lfo1_internal_depth  = 0;  
                 pLFO1->ExtController = 2; // MIDI controller 2  
                 bLFO1Enabled         = (pRegion->LFO1ControlDepth > 0);  
                 break;  
             case ::gig::lfo1_ctrl_internal_modwheel:  
                 lfo1_internal_depth  = pRegion->LFO1InternalDepth;  
                 pLFO1->ExtController = 1; // MIDI controller 1  
                 bLFO1Enabled         = (lfo1_internal_depth > 0 || pRegion->LFO1ControlDepth > 0);  
                 break;  
             case ::gig::lfo1_ctrl_internal_breath:  
                 lfo1_internal_depth  = pRegion->LFO1InternalDepth;  
                 pLFO1->ExtController = 2; // MIDI controller 2  
                 bLFO1Enabled         = (lfo1_internal_depth > 0 || pRegion->LFO1ControlDepth > 0);  
                 break;  
             default:  
                 lfo1_internal_depth  = 0;  
                 pLFO1->ExtController = 0; // no external controller  
                 bLFO1Enabled         = false;  
         }  
         if (bLFO1Enabled) {  
             pLFO1->trigger(pRegion->LFO1Frequency,  
                            start_level_min,  
                            lfo1_internal_depth,  
                            pRegion->LFO1ControlDepth,  
                            pRegion->LFO1FlipPhase,  
                            pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);  
             pLFO1->update(pLFO1->ExtController ? GetSfzEngineChannel()->ControllerTable[pLFO1->ExtController] : 0);  
         }*/ // TODO: ^^^  
         bLFO1Enabled = false;  
     }  
   
     void Voice::InitLFO2() {  
         /*uint16_t lfo2_internal_depth;  
         switch (pRegion->LFO2Controller) {  
             case ::gig::lfo2_ctrl_internal:  
                 lfo2_internal_depth  = pRegion->LFO2InternalDepth;  
                 pLFO2->ExtController = 0; // no external controller  
                 bLFO2Enabled         = (lfo2_internal_depth > 0);  
                 break;  
             case ::gig::lfo2_ctrl_modwheel:  
                 lfo2_internal_depth  = 0;  
                 pLFO2->ExtController = 1; // MIDI controller 1  
                 bLFO2Enabled         = (pRegion->LFO2ControlDepth > 0);  
                 break;  
             case ::gig::lfo2_ctrl_foot:  
                 lfo2_internal_depth  = 0;  
                 pLFO2->ExtController = 4; // MIDI controller 4  
                 bLFO2Enabled         = (pRegion->LFO2ControlDepth > 0);  
                 break;  
             case ::gig::lfo2_ctrl_internal_modwheel:  
                 lfo2_internal_depth  = pRegion->LFO2InternalDepth;  
                 pLFO2->ExtController = 1; // MIDI controller 1  
                 bLFO2Enabled         = (lfo2_internal_depth > 0 || pRegion->LFO2ControlDepth > 0);  
                 break;  
             case ::gig::lfo2_ctrl_internal_foot:  
                 lfo2_internal_depth  = pRegion->LFO2InternalDepth;  
                 pLFO2->ExtController = 4; // MIDI controller 4  
                 bLFO2Enabled         = (lfo2_internal_depth > 0 || pRegion->LFO2ControlDepth > 0);  
                 break;  
             default:  
                 lfo2_internal_depth  = 0;  
                 pLFO2->ExtController = 0; // no external controller  
                 bLFO2Enabled         = false;  
         }  
         if (bLFO2Enabled) {  
             pLFO2->trigger(pRegion->LFO2Frequency,  
                            start_level_max,  
                            lfo2_internal_depth,  
                            pRegion->LFO2ControlDepth,  
                            pRegion->LFO2FlipPhase,  
                            pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);  
             pLFO2->update(pLFO2->ExtController ? GetSfzEngineChannel()->ControllerTable[pLFO2->ExtController] : 0);  
         }*/ // TODO: ^^^  
         bLFO2Enabled = false;  
     }  
   
     void Voice::InitLFO3() {  
         /*uint16_t lfo3_internal_depth;  
         switch (pRegion->LFO3Controller) {  
             case ::gig::lfo3_ctrl_internal:  
                 lfo3_internal_depth  = pRegion->LFO3InternalDepth;  
                 pLFO3->ExtController = 0; // no external controller  
                 bLFO3Enabled         = (lfo3_internal_depth > 0);  
                 break;  
             case ::gig::lfo3_ctrl_modwheel:  
                 lfo3_internal_depth  = 0;  
                 pLFO3->ExtController = 1; // MIDI controller 1  
                 bLFO3Enabled         = (pRegion->LFO3ControlDepth > 0);  
                 break;  
             case ::gig::lfo3_ctrl_aftertouch:  
                 lfo3_internal_depth  = 0;  
                 pLFO3->ExtController = 128;  
                 bLFO3Enabled         = true;  
                 break;  
             case ::gig::lfo3_ctrl_internal_modwheel:  
                 lfo3_internal_depth  = pRegion->LFO3InternalDepth;  
                 pLFO3->ExtController = 1; // MIDI controller 1  
                 bLFO3Enabled         = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0);  
                 break;  
             case ::gig::lfo3_ctrl_internal_aftertouch:  
                 lfo3_internal_depth  = pRegion->LFO3InternalDepth;  
                 pLFO1->ExtController = 128;  
                 bLFO3Enabled         = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0);  
                 break;  
             default:  
                 lfo3_internal_depth  = 0;  
                 pLFO3->ExtController = 0; // no external controller  
                 bLFO3Enabled         = false;  
         }  
         if (bLFO3Enabled) {  
             pLFO3->trigger(pRegion->LFO3Frequency,  
                            start_level_mid,  
                            lfo3_internal_depth,  
                            pRegion->LFO3ControlDepth,  
                            false,  
                            pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);  
             pLFO3->update(pLFO3->ExtController ? GetSfzEngineChannel()->ControllerTable[pLFO3->ExtController] : 0);  
         }*/ // TODO: ^^^  
         bLFO3Enabled = false;  
     }  
   
276      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {
277          float cutoff = *pRegion->cutoff;          float cutoff = *pRegion->cutoff;
278          cutoff *= RTMath::CentsToFreqRatioUnlimited(          cutoff *= RTMath::CentsToFreqRatioUnlimited(

Legend:
Removed from v.2218  
changed lines
  Added in v.2224

  ViewVC Help
Powered by ViewVC