/[svn]/linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp

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

revision 2327 by persson, Sat Mar 10 16:16:14 2012 UTC revision 3561 by schoenebeck, Fri Aug 23 11:44:00 2019 UTC
# Line 142  namespace LinuxSampler { namespace sfz { Line 142  namespace LinuxSampler { namespace sfz {
142              f = GetInfluence(egInfo.node[i].time_oncc);              f = GetInfluence(egInfo.node[i].time_oncc);
143              egInfo.node[i].time = std::min(egInfo.node[i].time + f, 100.0f);              egInfo.node[i].time = std::min(egInfo.node[i].time + f, 100.0f);
144          }          }
145          EG.trigger(egInfo, GetSampleRate(), pVoice->MIDIVelocity);          EG.trigger(egInfo, GetSampleRate(), pVoice->MIDIVelocity());
146      }      }
147            
148            
# Line 151  namespace LinuxSampler { namespace sfz { Line 151  namespace LinuxSampler { namespace sfz {
151          depth = pRegion->pitcheg_depth + GetInfluence(pRegion->pitcheg_depth_oncc);          depth = pRegion->pitcheg_depth + GetInfluence(pRegion->pitcheg_depth_oncc);
152                    
153          // the length of the decay and release curves are dependent on the velocity          // the length of the decay and release curves are dependent on the velocity
154          const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity);          const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity());
155    
156          // set the delay trigger          // set the delay trigger
157          float delay = pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease;          float delay = pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease;
# Line 187  namespace LinuxSampler { namespace sfz { Line 187  namespace LinuxSampler { namespace sfz {
187          depth = pRegion->fileg_depth + GetInfluence(pRegion->fileg_depth_oncc);          depth = pRegion->fileg_depth + GetInfluence(pRegion->fileg_depth_oncc);
188                    
189          // the length of the decay and release curves are dependent on the velocity          // the length of the decay and release curves are dependent on the velocity
190          const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity);          const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity());
191    
192          // set the delay trigger          // set the delay trigger
193          float delay = pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease;          float delay = pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease;
# Line 222  namespace LinuxSampler { namespace sfz { Line 222  namespace LinuxSampler { namespace sfz {
222          ::sfz::Region* const pRegion = pVoice->pRegion;          ::sfz::Region* const pRegion = pVoice->pRegion;
223                    
224          // the length of the decay and release curves are dependent on the velocity          // the length of the decay and release curves are dependent on the velocity
225          const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity);          const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity());
226    
227          // set the delay trigger          // set the delay trigger
228          float delay = pRegion->ampeg_delay + pRegion->ampeg_vel2delay * velrelease;          float delay = pRegion->ampeg_delay + pRegion->ampeg_vel2delay * velrelease;
# Line 242  namespace LinuxSampler { namespace sfz { Line 242  namespace LinuxSampler { namespace sfz {
242                    
243          float sustain = pRegion->ampeg_sustain + pRegion->ampeg_vel2sustain * velrelease;          float sustain = pRegion->ampeg_sustain + pRegion->ampeg_vel2sustain * velrelease;
244          sustain = 10 * (sustain + GetInfluence(pRegion->ampeg_sustaincc));          sustain = 10 * (sustain + GetInfluence(pRegion->ampeg_sustaincc));
245                    if (pVoice->pNote) {
246                pVoice->pNote->Override.Sustain.applyTo(sustain);
247            }
248    
249          float release = pRegion->ampeg_release + pRegion->ampeg_vel2release * velrelease;          float release = pRegion->ampeg_release + pRegion->ampeg_vel2release * velrelease;
250          release = std::max(0.0f, release + GetInfluence(pRegion->ampeg_releasecc));          release = std::max(0.0f, release + GetInfluence(pRegion->ampeg_releasecc));
251                    
# Line 255  namespace LinuxSampler { namespace sfz { Line 258  namespace LinuxSampler { namespace sfz {
258            
259      LFOUnit::LFOUnit(SfzSignalUnitRack* rack)      LFOUnit::LFOUnit(SfzSignalUnitRack* rack)
260          : SfzSignalUnit(rack), pLfoInfo(NULL), pLFO(NULL),          : SfzSignalUnit(rack), pLfoInfo(NULL), pLFO(NULL),
261            suFadeEG(rack), suFreqOnCC(rack, this), suDepthOnCC(rack)            suFadeEG(rack), suDepthOnCC(rack), suFreqOnCC(rack, this)
262      { }      { }
263            
264      LFOUnit::LFOUnit(const LFOUnit& Unit)      LFOUnit::LFOUnit(const LFOUnit& Unit)
265          : SfzSignalUnit(Unit), suFadeEG(static_cast<SfzSignalUnitRack*>(Unit.pRack)),          : SfzSignalUnit(Unit), suFadeEG(static_cast<SfzSignalUnitRack*>(Unit.pRack)),
266            suFreqOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack), this),            suDepthOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack)),
267            suDepthOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack))            suFreqOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack), this)
268      {      {
269          Copy(Unit);          Copy(Unit);
270      }      }
# Line 306  namespace LinuxSampler { namespace sfz { Line 309  namespace LinuxSampler { namespace sfz {
309              start_level_mid,              start_level_mid,
310              1, 0, false, GetSampleRate()              1, 0, false, GetSampleRate()
311          );          );
312          lfo.update(0);          lfo.updateByMIDICtrlValue(0);
313      }      }
314            
315            
# Line 328  namespace LinuxSampler { namespace sfz { Line 331  namespace LinuxSampler { namespace sfz {
331      void LFOv2Unit::Trigger() {      void LFOv2Unit::Trigger() {
332          LFOUnit::Trigger();          LFOUnit::Trigger();
333                    
334          if (pLfoInfo->wave < 0 || pLfoInfo->wave >= lfos.size()) pLFO = &lfo0;          if (/*pLfoInfo->wave < 0 ||*/ pLfoInfo->wave >= lfos.size()) pLFO = &lfo0;
335          else pLFO = lfos[pLfoInfo->wave];          else pLFO = lfos[pLfoInfo->wave];
336                    
337          pLFO->Trigger (          pLFO->Trigger (
# Line 483  namespace LinuxSampler { namespace sfz { Line 486  namespace LinuxSampler { namespace sfz {
486    
487    
488      EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack)      EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack)
489          : EndpointSignalUnit(rack), suXFInCC(rack), suXFOutCC(rack), suPanOnCC(rack), pitchVeltrackRatio(0)          : EndpointSignalUnit(rack), pitchVeltrackRatio(0), suXFInCC(rack), suXFOutCC(rack), suPanOnCC(rack)
490      {      {
491                    
492      }      }
493            
494      float EndpointUnit::GetInfluence(::sfz::Array< ::sfz::optional<float> >& cc) {      float EndpointUnit::GetInfluence(::sfz::Array< optional<float> >& cc) {
495          float f = 0;          float f = 0;
496          for (int i = 0; i < 128; i++) {          for (int i = 0; i < 128; i++) {
497              if (cc[i]) {              if (cc[i]) {
# Line 498  namespace LinuxSampler { namespace sfz { Line 501  namespace LinuxSampler { namespace sfz {
501          return f;          return f;
502      }      }
503            
504      float EndpointUnit::GetInfluence(::sfz::Array< ::sfz::optional<int> >& cc) {      float EndpointUnit::GetInfluence(::sfz::Array< optional<int> >& cc) {
505          float f = 0;          float f = 0;
506          for (int i = 0; i < 128; i++) {          for (int i = 0; i < 128; i++) {
507              if (cc[i]) {              if (cc[i]) {
# Line 530  namespace LinuxSampler { namespace sfz { Line 533  namespace LinuxSampler { namespace sfz {
533                    
534          float xfInVelCoeff = 1;          float xfInVelCoeff = 1;
535                    
536          if (pVoice->MIDIVelocity <= pVoice->pRegion->xfin_lovel) {          if (pVoice->MIDIVelocity() <= pVoice->pRegion->xfin_lovel) {
537              xfInVelCoeff = 0;              xfInVelCoeff = 0;
538          } else if (pVoice->MIDIVelocity >= pVoice->pRegion->xfin_hivel) {          } else if (pVoice->MIDIVelocity() >= pVoice->pRegion->xfin_hivel) {
539              xfInVelCoeff = 1;              xfInVelCoeff = 1;
540          } else {          } else {
541              float xfVelSize = pVoice->pRegion->xfin_hivel - pVoice->pRegion->xfin_lovel;              float xfVelSize = pVoice->pRegion->xfin_hivel - pVoice->pRegion->xfin_lovel;
542              float velPos = pVoice->MIDIVelocity - pVoice->pRegion->xfin_lovel;              float velPos = pVoice->MIDIVelocity() - pVoice->pRegion->xfin_lovel;
543              xfInVelCoeff = velPos / xfVelSize;              xfInVelCoeff = velPos / xfVelSize;
544              if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) {              if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) {
545                  xfInVelCoeff = sin(xfInVelCoeff * M_PI / 2.0);                  xfInVelCoeff = sin(xfInVelCoeff * M_PI / 2.0);
# Line 545  namespace LinuxSampler { namespace sfz { Line 548  namespace LinuxSampler { namespace sfz {
548                    
549          float xfOutVelCoeff = 1;          float xfOutVelCoeff = 1;
550                    
551          if (pVoice->MIDIVelocity >= pVoice->pRegion->xfout_hivel) {          if (pVoice->MIDIVelocity() >= pVoice->pRegion->xfout_hivel) {
552              if (pVoice->pRegion->xfout_lovel < 127 /* is set */) xfOutVelCoeff = 0;              if (pVoice->pRegion->xfout_lovel < 127 /* is set */) xfOutVelCoeff = 0;
553          } else if (pVoice->MIDIVelocity <= pVoice->pRegion->xfout_lovel) {          } else if (pVoice->MIDIVelocity() <= pVoice->pRegion->xfout_lovel) {
554              xfOutVelCoeff = 1;              xfOutVelCoeff = 1;
555          } else {          } else {
556              float xfVelSize = pVoice->pRegion->xfout_hivel - pVoice->pRegion->xfout_lovel;              float xfVelSize = pVoice->pRegion->xfout_hivel - pVoice->pRegion->xfout_lovel;
557              float velPos = pVoice->MIDIVelocity - pVoice->pRegion->xfout_lovel;              float velPos = pVoice->MIDIVelocity() - pVoice->pRegion->xfout_lovel;
558              xfOutVelCoeff = 1.0f - velPos / xfVelSize;              xfOutVelCoeff = 1.0f - velPos / xfVelSize;
559              if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) {              if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) {
560                  xfOutVelCoeff = sin(xfOutVelCoeff * M_PI / 2.0);                  xfOutVelCoeff = sin(xfOutVelCoeff * M_PI / 2.0);
# Line 560  namespace LinuxSampler { namespace sfz { Line 563  namespace LinuxSampler { namespace sfz {
563                    
564          float xfInKeyCoeff = 1;          float xfInKeyCoeff = 1;
565                    
566          if (pVoice->MIDIKey <= pVoice->pRegion->xfin_lokey) {          if (pVoice->MIDIKey() <= pVoice->pRegion->xfin_lokey) {
567              if (pVoice->pRegion->xfin_hikey > 0 /* is set */) xfInKeyCoeff = 0;              if (pVoice->pRegion->xfin_hikey > 0 /* is set */) xfInKeyCoeff = 0;
568          } else if (pVoice->MIDIKey >= pVoice->pRegion->xfin_hikey) {          } else if (pVoice->MIDIKey() >= pVoice->pRegion->xfin_hikey) {
569              xfInKeyCoeff = 1;              xfInKeyCoeff = 1;
570          } else {          } else {
571              float xfKeySize = pVoice->pRegion->xfin_hikey - pVoice->pRegion->xfin_lokey;              float xfKeySize = pVoice->pRegion->xfin_hikey - pVoice->pRegion->xfin_lokey;
572              float keyPos = pVoice->MIDIKey - pVoice->pRegion->xfin_lokey;              float keyPos = pVoice->MIDIKey() - pVoice->pRegion->xfin_lokey;
573              xfInKeyCoeff = keyPos / xfKeySize;              xfInKeyCoeff = keyPos / xfKeySize;
574              if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) {              if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) {
575                  xfInKeyCoeff = sin(xfInKeyCoeff * M_PI / 2.0);                  xfInKeyCoeff = sin(xfInKeyCoeff * M_PI / 2.0);
# Line 575  namespace LinuxSampler { namespace sfz { Line 578  namespace LinuxSampler { namespace sfz {
578                    
579          float xfOutKeyCoeff = 1;          float xfOutKeyCoeff = 1;
580                    
581          if (pVoice->MIDIKey >= pVoice->pRegion->xfout_hikey) {          if (pVoice->MIDIKey() >= pVoice->pRegion->xfout_hikey) {
582              if (pVoice->pRegion->xfout_lokey < 127 /* is set */) xfOutKeyCoeff = 0;              if (pVoice->pRegion->xfout_lokey < 127 /* is set */) xfOutKeyCoeff = 0;
583          } else if (pVoice->MIDIKey <= pVoice->pRegion->xfout_lokey) {          } else if (pVoice->MIDIKey() <= pVoice->pRegion->xfout_lokey) {
584              xfOutKeyCoeff = 1;              xfOutKeyCoeff = 1;
585          } else {          } else {
586              float xfKeySize = pVoice->pRegion->xfout_hikey - pVoice->pRegion->xfout_lokey;              float xfKeySize = pVoice->pRegion->xfout_hikey - pVoice->pRegion->xfout_lokey;
587              float keyPos = pVoice->MIDIKey - pVoice->pRegion->xfout_lokey;              float keyPos = pVoice->MIDIKey() - pVoice->pRegion->xfout_lokey;
588              xfOutKeyCoeff = 1.0f - keyPos / xfKeySize;              xfOutKeyCoeff = 1.0f - keyPos / xfKeySize;
589              if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) {              if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) {
590                  xfOutKeyCoeff = sin(xfOutKeyCoeff * M_PI / 2.0);                  xfOutKeyCoeff = sin(xfOutKeyCoeff * M_PI / 2.0);
# Line 595  namespace LinuxSampler { namespace sfz { Line 598  namespace LinuxSampler { namespace sfz {
598                    
599          suPanOnCC.SetCCs(pVoice->pRegion->pan_oncc);          suPanOnCC.SetCCs(pVoice->pRegion->pan_oncc);
600                    
601          pitchVeltrackRatio = RTMath::CentsToFreqRatioUnlimited((pVoice->MIDIVelocity / 127.0f) * pVoice->pRegion->pitch_veltrack);          pitchVeltrackRatio = RTMath::CentsToFreqRatioUnlimited((pVoice->MIDIVelocity() / 127.0f) * pVoice->pRegion->pitch_veltrack);
602      }      }
603            
604      bool EndpointUnit::Active() {      bool EndpointUnit::Active() {
# Line 771  namespace LinuxSampler { namespace sfz { Line 774  namespace LinuxSampler { namespace sfz {
774              pan += lfo->GetLevel() * (lfo->pLfoInfo->pan + f);              pan += lfo->GetLevel() * (lfo->pLfoInfo->pan + f);
775          }          }
776                    
         if(pan < -100) return -100;  
         if(pan >  100) return  100;  
           
777          return pan;          return pan;
778      }      }
779            
780            
781      SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice)      SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice)
782          : SignalUnitRack(MaxUnitCount), EqUnitSupport(this, voice), pVoice(voice),          : SignalUnitRack(MaxUnitCount), EqUnitSupport(this, voice),
783          suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this),          suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this),
784            suAmpLFO(this), suPitchLFO(this), suFilLFO(this),
785            suVolOnCC(this), suPitchOnCC(this), suCutoffOnCC(this), suResOnCC(this),
786          EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount),          EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount),
787          resEGs(maxEgCount), panEGs(maxEgCount), eqEGs(maxEgCount),          resEGs(maxEgCount), panEGs(maxEgCount), eqEGs(maxEgCount),
         suVolOnCC(this), suPitchOnCC(this), suCutoffOnCC(this), suResOnCC(this),  
         suAmpLFO(this), suPitchLFO(this), suFilLFO(this),  
788          LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount),          LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount),
789          filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount), eqLFOs(maxLfoCount)          filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount), eqLFOs(maxLfoCount),
790            pVoice(voice)
791      {      {
792          suEndpoint.pVoice = suEndpoint.suXFInCC.pVoice = suEndpoint.suXFOutCC.pVoice = suEndpoint.suPanOnCC.pVoice = voice;          suEndpoint.pVoice = suEndpoint.suXFInCC.pVoice = suEndpoint.suXFOutCC.pVoice = suEndpoint.suPanOnCC.pVoice = voice;
793          suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice;          suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice;
# Line 1201  namespace LinuxSampler { namespace sfz { Line 1202  namespace LinuxSampler { namespace sfz {
1202          float bw2 = (suEq2BwOnCC.Active() ? suEq2BwOnCC.GetLevel() : 0) + pRegion->eq2_bw;          float bw2 = (suEq2BwOnCC.Active() ? suEq2BwOnCC.GetLevel() : 0) + pRegion->eq2_bw;
1203          float bw3 = (suEq3BwOnCC.Active() ? suEq3BwOnCC.GetLevel() : 0) + pRegion->eq3_bw;          float bw3 = (suEq3BwOnCC.Active() ? suEq3BwOnCC.GetLevel() : 0) + pRegion->eq3_bw;
1204                    
1205          const float vel = pVoice->MIDIVelocity / 127.0f;          const float vel = pVoice->MIDIVelocity() / 127.0f;
1206                    
1207          dB1 += pRegion->eq1_vel2gain * vel;          dB1 += pRegion->eq1_vel2gain * vel;
1208          dB2 += pRegion->eq2_vel2gain * vel;          dB2 += pRegion->eq2_vel2gain * vel;

Legend:
Removed from v.2327  
changed lines
  Added in v.3561

  ViewVC Help
Powered by ViewVC