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

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

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

revision 2015 by iliev, Sun Oct 25 22:22:52 2009 UTC revision 2175 by persson, Mon Apr 25 08:12:36 2011 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 - 2008 Christian Schoenebeck                       *
7   *   Copyright (C) 2009 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 33  Line 33 
33  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
34    
35      Voice::Voice() {      Voice::Voice() {
36          pEngine     = NULL;          pEngine = NULL;
37            pEG1 = &EG1;
38            pEG2 = &EG2;
39      }      }
40    
41      Voice::~Voice() {      Voice::~Voice() {
           
42      }      }
43    
44      EngineChannel* Voice::GetGigEngineChannel() {      EngineChannel* Voice::GetGigEngineChannel() {
# Line 95  namespace LinuxSampler { namespace gig { Line 96  namespace LinuxSampler { namespace gig {
96          ri.EG3Attack     = pRegion->EG3Attack;          ri.EG3Attack     = pRegion->EG3Attack;
97          ri.EG3Depth      = pRegion->EG3Depth;          ri.EG3Depth      = pRegion->EG3Depth;
98          ri.VCFEnabled    = pRegion->VCFEnabled;          ri.VCFEnabled    = pRegion->VCFEnabled;
99          ri.VCFType       = pRegion->VCFType;          ri.VCFType       = Filter::vcf_type_t(pRegion->VCFType);
100          ri.VCFResonance  = pRegion->VCFResonance;          ri.VCFResonance  = pRegion->VCFResonance;
101    
102          ri.ReleaseTriggerDecay = pRegion->ReleaseTriggerDecay;          ri.ReleaseTriggerDecay = 0.01053 * (256 >> pRegion->ReleaseTriggerDecay);
103    
104          return ri;          return ri;
105      }      }
# Line 135  namespace LinuxSampler { namespace gig { Line 136  namespace LinuxSampler { namespace gig {
136      void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) {      void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) {
137          int ccvalue = itEvent->Param.CC.Value;          int ccvalue = itEvent->Param.CC.Value;
138          if (VCFCutoffCtrl.value == ccvalue) return;          if (VCFCutoffCtrl.value == ccvalue) return;
139          VCFCutoffCtrl.value == ccvalue;          VCFCutoffCtrl.value = ccvalue;
140          if (pRegion->VCFCutoffControllerInvert)  ccvalue = 127 - ccvalue;          if (pRegion->VCFCutoffControllerInvert)  ccvalue = 127 - ccvalue;
141          if (ccvalue < pRegion->VCFVelocityScale) ccvalue = pRegion->VCFVelocityScale;          if (ccvalue < pRegion->VCFVelocityScale) ccvalue = pRegion->VCFVelocityScale;
142          float cutoff = CutoffBase * float(ccvalue);          float cutoff = CutoffBase * float(ccvalue);
# Line 341  namespace LinuxSampler { namespace gig { Line 342  namespace LinuxSampler { namespace gig {
342                  break;                  break;
343              case ::gig::lfo3_ctrl_internal_aftertouch:              case ::gig::lfo3_ctrl_internal_aftertouch:
344                  lfo3_internal_depth  = pRegion->LFO3InternalDepth;                  lfo3_internal_depth  = pRegion->LFO3InternalDepth;
345                  pLFO1->ExtController = 128;                  pLFO3->ExtController = 128;
346                  bLFO3Enabled         = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0);                  bLFO3Enabled         = (lfo3_internal_depth > 0 || pRegion->LFO3ControlDepth > 0);
347                  break;                  break;
348              default:              default:
# Line 359  namespace LinuxSampler { namespace gig { Line 360  namespace LinuxSampler { namespace gig {
360              pLFO3->update(pLFO3->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO3->ExtController] : 0);              pLFO3->update(pLFO3->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO3->ExtController] : 0);
361          }          }
362      }      }
363        
364      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {
365          float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity);          float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity);
366          if (pRegion->VCFKeyboardTracking) {          if (pRegion->VCFKeyboardTracking) {
367              cutoff *= exp((MIDIKeyVelocity - pRegion->VCFKeyboardTrackingBreakpoint) * 0.057762265f); // (ln(2) / 12)              cutoff *= RTMath::CentsToFreqRatioUnlimited((MIDIKey - pRegion->VCFKeyboardTrackingBreakpoint) * 100);
368          }          }
369          return cutoff;          return cutoff;
370      }      }
# Line 450  namespace LinuxSampler { namespace gig { Line 451  namespace LinuxSampler { namespace gig {
451          return ctrl;          return ctrl;
452      }      }
453    
454        void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {
455            EG1.trigger(uint(RgnInfo.EG1PreAttack),
456                        RgnInfo.EG1Attack * egInfo.Attack,
457                        RgnInfo.EG1Hold,
458                        RgnInfo.EG1Decay1 * egInfo.Decay * velrelease,
459                        RgnInfo.EG1Decay2 * egInfo.Decay * velrelease,
460                        RgnInfo.EG1InfiniteSustain,
461                        uint(RgnInfo.EG1Sustain),
462                        RgnInfo.EG1Release * egInfo.Release * velrelease,
463                        velocityAttenuation,
464                        sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
465        }
466    
467        void Voice::TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {
468            EG2.trigger(uint(RgnInfo.EG2PreAttack),
469                        RgnInfo.EG2Attack * egInfo.Attack,
470                        false,
471                        RgnInfo.EG2Decay1 * egInfo.Decay * velrelease,
472                        RgnInfo.EG2Decay2 * egInfo.Decay * velrelease,
473                        RgnInfo.EG2InfiniteSustain,
474                        uint(RgnInfo.EG2Sustain),
475                        RgnInfo.EG2Release * egInfo.Release * velrelease,
476                        velocityAttenuation,
477                        sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
478        }
479    
480        void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) {
481            dmsg(4,("Voice %x processGroupEvents event type=%d", this, itEvent->Type));
482    
483            // TODO: The SustainPedal condition could be wrong, maybe the
484            // check should be if this Voice is in release stage or is a
485            // release sample instead. Need to test this in GSt.
486            if (itEvent->Param.Note.Key != MIDIKey ||
487                !GetGigEngineChannel()->SustainPedal) {
488                dmsg(4,("Voice %x - kill", this));
489    
490                // kill the voice fast
491                pEG1->enterFadeOutStage();
492            }
493        }
494    
495  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

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

  ViewVC Help
Powered by ViewVC