/[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 2203 by persson, Sat Jul 9 16:44:27 2011 UTC revision 2408 by persson, Sat Feb 2 08:22:49 2013 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 - 2013 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 181  namespace LinuxSampler { namespace gig { Line 181  namespace LinuxSampler { namespace gig {
181      Voice::EGInfo Voice::CalculateEG1ControllerInfluence(double eg1ControllerValue) {      Voice::EGInfo Voice::CalculateEG1ControllerInfluence(double eg1ControllerValue) {
182          EGInfo eg;          EGInfo eg;
183          // (eg1attack is different from the others)          // (eg1attack is different from the others)
184          eg.Attack  = (pRegion->EG1ControllerAttackInfluence)  ?          if (pRegion->EG1Attack < 1e-8 && // attack in gig == 0
185              1 + 0.031 * (double) (pRegion->EG1ControllerAttackInfluence == 1 ?              (pRegion->EG1ControllerAttackInfluence == 0 ||
186                                    1 : 1 << pRegion->EG1ControllerAttackInfluence) * eg1ControllerValue : 1.0;               eg1ControllerValue <= 10)) { // strange GSt special case
187                eg.Attack = 0; // this will force the attack to be 0 in the call to EG1.trigger
188            } else {
189                eg.Attack  = (pRegion->EG1ControllerAttackInfluence)  ?
190                    1 + 0.031 * (double) (pRegion->EG1ControllerAttackInfluence == 1 ?
191                                          1 : 1 << pRegion->EG1ControllerAttackInfluence) * eg1ControllerValue : 1.0;
192            }
193          eg.Decay   = (pRegion->EG1ControllerDecayInfluence)   ? 1 + 0.00775 * (double) (1 << pRegion->EG1ControllerDecayInfluence)   * eg1ControllerValue : 1.0;          eg.Decay   = (pRegion->EG1ControllerDecayInfluence)   ? 1 + 0.00775 * (double) (1 << pRegion->EG1ControllerDecayInfluence)   * eg1ControllerValue : 1.0;
194          eg.Release = (pRegion->EG1ControllerReleaseInfluence) ? 1 + 0.00775 * (double) (1 << pRegion->EG1ControllerReleaseInfluence) * eg1ControllerValue : 1.0;          eg.Release = (pRegion->EG1ControllerReleaseInfluence) ? 1 + 0.00775 * (double) (1 << pRegion->EG1ControllerReleaseInfluence) * eg1ControllerValue : 1.0;
195    
# Line 444  namespace LinuxSampler { namespace gig { Line 450  namespace LinuxSampler { namespace gig {
450    
451      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) {
452          EG1.trigger(pRegion->EG1PreAttack,          EG1.trigger(pRegion->EG1PreAttack,
453                      pRegion->EG1Attack * egInfo.Attack,                      RTMath::Max(pRegion->EG1Attack, 0.0316) * egInfo.Attack,
454                      pRegion->EG1Hold,                      pRegion->EG1Hold,
455                      pRegion->EG1Decay1 * egInfo.Decay * velrelease,                      pRegion->EG1Decay1 * egInfo.Decay * velrelease,
456                      pRegion->EG1Decay2 * egInfo.Decay * velrelease,                      pRegion->EG1Decay2 * egInfo.Decay * velrelease,
457                      pRegion->EG1InfiniteSustain,                      pRegion->EG1InfiniteSustain,
458                      pRegion->EG1Sustain,                      pRegion->EG1Sustain,
459                      pRegion->EG1Release * egInfo.Release * velrelease,                      RTMath::Max(pRegion->EG1Release * velrelease, 0.014) * egInfo.Release,
460                      velocityAttenuation,                      velocityAttenuation,
461                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
462      }      }
# Line 474  namespace LinuxSampler { namespace gig { Line 480  namespace LinuxSampler { namespace gig {
480          // TODO: The SustainPedal condition could be wrong, maybe the          // TODO: The SustainPedal condition could be wrong, maybe the
481          // check should be if this Voice is in release stage or is a          // check should be if this Voice is in release stage or is a
482          // release sample instead. Need to test this in GSt.          // release sample instead. Need to test this in GSt.
483          if (itEvent->Param.Note.Key != MIDIKey ||          // -- Andreas
484              !GetGigEngineChannel()->SustainPedal) {          //
485            // Commented sustain pedal check out. I don't think voices of the same
486            // note should be stopped at all, because it doesn't sound naturally
487            // with a drumkit.
488            // -- Christian, 2013-01-08
489            if (itEvent->Param.Note.Key != MIDIKey /*||
490                !GetGigEngineChannel()->SustainPedal*/) {
491              dmsg(4,("Voice %x - kill", this));              dmsg(4,("Voice %x - kill", this));
492    
493              // kill the voice fast              // kill the voice fast
# Line 483  namespace LinuxSampler { namespace gig { Line 495  namespace LinuxSampler { namespace gig {
495          }          }
496      }      }
497    
498        void Voice::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) {
499            EG1.CalculateFadeOutCoeff(FadeOutTime, SampleRate);
500        }
501    
502        int Voice::CalculatePan(uint8_t pan) {
503            int p;
504            // Gst behaviour: -64 and 63 are special cases
505            if (RgnInfo.Pan == -64)     p = pan * 2 - 127;
506            else if (RgnInfo.Pan == 63) p = pan * 2;
507            else                        p = pan + RgnInfo.Pan;
508    
509            if (p < 0) return 0;
510            if (p > 127) return 127;
511            return p;
512        }
513    
514  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

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

  ViewVC Help
Powered by ViewVC