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

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

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

revision 2055 by persson, Sat Jan 30 10:30:02 2010 UTC revision 2203 by persson, Sat Jul 9 16:44:27 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 32  namespace LinuxSampler { namespace sf2 { Line 32  namespace LinuxSampler { namespace sf2 {
32      Voice::Voice() {      Voice::Voice() {
33          pEngine = NULL;          pEngine = NULL;
34          pEG1 = &EG1;          pEG1 = &EG1;
35            pEG2 = &EG2;
36      }      }
37    
38      Voice::~Voice() {      Voice::~Voice() {
# Line 71  namespace LinuxSampler { namespace sf2 { Line 72  namespace LinuxSampler { namespace sf2 {
72          ::sf2::Preset* preset = GetSf2EngineChannel()->pInstrument;          ::sf2::Preset* preset = GetSf2EngineChannel()->pInstrument;
73          for (int i = 0; i < preset->GetRegionCount(); i++) { // TODO: some optimization?          for (int i = 0; i < preset->GetRegionCount(); i++) { // TODO: some optimization?
74              if (preset->GetRegion(i)->pInstrument == pRegion->GetParentInstrument()) {              if (preset->GetRegion(i)->pInstrument == pRegion->GetParentInstrument()) {
75                  reg = preset->GetRegion(i); // TODO: Can the instrument belongs to more than one preset regions?                  reg = preset->GetRegion(i); // TODO: Can the instrument belong to more than one preset region?
76                  break;                  break;
77              }              }
78          }          }
79                    pPresetRegion = reg;
80    
81          RegionInfo ri;          RegionInfo ri;
82          ri.UnityNote = pRegion->GetUnityNote();          ri.UnityNote = pRegion->GetUnityNote();
83          ri.FineTune  = pRegion->GetFineTune(reg) + (pRegion->GetCoarseTune(reg) * 100);          ri.FineTune  = pRegion->GetFineTune(reg) + (pRegion->GetCoarseTune(reg) * 100);
84          ri.Pan       = pRegion->GetPan(reg);          ri.Pan       = pRegion->GetPan(reg);
85          ri.SampleStartOffset = pRegion->startAddrsOffset + pRegion->startAddrsCoarseOffset;          ri.SampleStartOffset = pRegion->startAddrsOffset + pRegion->startAddrsCoarseOffset;
86    
         // sample amplitude  
         ri.EG1PreAttack        = 1000;  
         ri.EG1Attack           = pRegion->GetEG1Attack(reg);  
         ri.EG1Hold             = pRegion->GetEG1Hold(reg);  
         ri.EG1Decay1           = pRegion->GetEG1Decay(reg);  
         ri.EG1Decay2           = pRegion->GetEG1Decay(reg);  
         ri.EG1Sustain          = pRegion->GetEG1Sustain(reg);  
         ri.EG1InfiniteSustain  = true;  
         ri.EG1Release          = pRegion->GetEG1Release(reg);  
   
87          // filter cutoff frequency          // filter cutoff frequency
88          ri.EG2PreAttack        = 1000;          ri.EG2PreAttack        = 1000;
89          ri.EG2Attack           = pRegion->GetEG2Attack(reg);          ri.EG2Attack           = pRegion->GetEG2Attack(reg);
# Line 106  namespace LinuxSampler { namespace sf2 { Line 98  namespace LinuxSampler { namespace sf2 {
98          ri.EG3Attack     = 0; // TODO:          ri.EG3Attack     = 0; // TODO:
99          ri.EG3Depth      = 0; // TODO:          ri.EG3Depth      = 0; // TODO:
100          ri.VCFEnabled    = false; // TODO:          ri.VCFEnabled    = false; // TODO:
101          ri.VCFType       = ::gig::vcf_type_lowpass; // TODO:          ri.VCFType       = Filter::vcf_type_2p_lowpass; // TODO:
102          ri.VCFResonance  = 0; // TODO:          ri.VCFResonance  = 0; // TODO:
103    
104          ri.ReleaseTriggerDecay = 0; // TODO:          ri.ReleaseTriggerDecay = 0; // TODO:
# Line 217  namespace LinuxSampler { namespace sf2 { Line 209  namespace LinuxSampler { namespace sf2 {
209      }      }
210    
211      void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {      void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {
212          EG1.trigger(uint(RgnInfo.EG1PreAttack),          EG1.trigger(0,
213                      RgnInfo.EG1Attack * egInfo.Attack,                      pRegion->GetEG1Attack(pPresetRegion),
214                      RgnInfo.EG1Hold,                      pRegion->GetEG1Hold(pPresetRegion),
215                      RgnInfo.EG1Decay1 * egInfo.Decay * velrelease,                      pRegion->GetEG1Decay(pPresetRegion),
216                      RgnInfo.EG1Decay2 * egInfo.Decay * velrelease,                      uint(pRegion->GetEG1Sustain(pPresetRegion)),
217                      RgnInfo.EG1InfiniteSustain,                      pRegion->GetEG1Release(pPresetRegion),
                     uint(RgnInfo.EG1Sustain),  
                     RgnInfo.EG1Release * egInfo.Release * velrelease,  
                     velocityAttenuation,  
218                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
219      }      }
220    
# Line 265  namespace LinuxSampler { namespace sf2 { Line 254  namespace LinuxSampler { namespace sf2 {
254          return eg;          return eg;
255      }      }
256    
257        void Voice::TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {
258            EG2.trigger(uint(RgnInfo.EG2PreAttack),
259                        RgnInfo.EG2Attack * egInfo.Attack,
260                        false,
261                        RgnInfo.EG2Decay1 * egInfo.Decay * velrelease,
262                        RgnInfo.EG2Decay2 * egInfo.Decay * velrelease,
263                        RgnInfo.EG2InfiniteSustain,
264                        uint(RgnInfo.EG2Sustain),
265                        RgnInfo.EG2Release * egInfo.Release * velrelease,
266                        velocityAttenuation,
267                        sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
268        }
269    
270      void Voice::InitLFO1() {      void Voice::InitLFO1() {
271          /*uint16_t lfo1_internal_depth;          /*uint16_t lfo1_internal_depth;
272          switch (pRegion->LFO1Controller) {          switch (pRegion->LFO1Controller) {
# Line 403  namespace LinuxSampler { namespace sf2 { Line 405  namespace LinuxSampler { namespace sf2 {
405      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {      float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) {
406          /*float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity);          /*float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity);
407          if (pRegion->VCFKeyboardTracking) {          if (pRegion->VCFKeyboardTracking) {
408              cutoff *= exp((MIDIKeyVelocity - pRegion->VCFKeyboardTrackingBreakpoint) * 0.057762265f); // (ln(2) / 12)              cutoff *= RTMath::CentsToFreqRatioUnlimited((MIDIKey - pRegion->VCFKeyboardTrackingBreakpoint) * 100);
409          }          }
410          return cutoff;*/ // TODO: ^^^          return cutoff;*/ // TODO: ^^^
411          return 1.0f;          return 1.0f;
# Line 494  namespace LinuxSampler { namespace sf2 { Line 496  namespace LinuxSampler { namespace sf2 {
496          return 0;          return 0;
497      }      }
498    
499        void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) {
500            if (itEvent->Param.Note.Key != MIDIKey) {
501                // kill the voice fast
502                pEG1->enterFadeOutStage();
503            }
504        }
505    
506  }} // namespace LinuxSampler::sf2  }} // namespace LinuxSampler::sf2

Legend:
Removed from v.2055  
changed lines
  Added in v.2203

  ViewVC Help
Powered by ViewVC