/[svn]/linuxsampler/trunk/src/engines/common/AbstractVoice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/AbstractVoice.cpp

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

revision 2879 by schoenebeck, Tue Apr 19 14:07:53 2016 UTC revision 2938 by schoenebeck, Mon Jul 11 17:10:40 2016 UTC
# Line 146  namespace LinuxSampler { Line 146  namespace LinuxSampler {
146          float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;          float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;
147          CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate);          CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate);
148          VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate);          VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate);
149            NoteVolumeSmoother.trigger(pNote ? pNote->Override.Volume : 1.f, subfragmentRate);
150    
151          // Check if the sample needs disk streaming or is too short for that          // Check if the sample needs disk streaming or is too short for that
152          long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize;          long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize;
# Line 185  namespace LinuxSampler { Line 186  namespace LinuxSampler {
186          }          }
187    
188          Pitch = CalculatePitchInfo(PitchBend);          Pitch = CalculatePitchInfo(PitchBend);
189            NotePitch = (pNote) ? pNote->Override.Pitch : 1.0f;
190            NoteCutoff = (pNote) ? pNote->Override.Cutoff : 1.0f;
191            NoteResonance = (pNote) ? pNote->Override.Resonance : 1.0f;
192    
193          // 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
194          const double velrelease = 1 / GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity);          const double velrelease = 1 / GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity);
# Line 201  namespace LinuxSampler { Line 205  namespace LinuxSampler {
205              pSignalUnitRack->Trigger();              pSignalUnitRack->Trigger();
206          }          }
207    
208          uint8_t pan = MIDIPan;          const uint8_t pan = (pSignalUnitRack) ? pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan) : MIDIPan;
209          if (pSignalUnitRack) pan = pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan);          NotePanLeft  = (pNote) ? AbstractEngine::PanCurveValueNorm(pNote->Override.Pan, 0 /*left*/ ) : 1.f;
210          PanLeftSmoother.trigger(AbstractEngine::PanCurve[128 - pan], subfragmentRate);          NotePanRight = (pNote) ? AbstractEngine::PanCurveValueNorm(pNote->Override.Pan, 1 /*right*/) : 1.f;
211          PanRightSmoother.trigger(AbstractEngine::PanCurve[pan], subfragmentRate);          PanLeftSmoother.trigger(
212                AbstractEngine::PanCurve[128 - pan] * NotePanLeft,
213                subfragmentRate
214            );
215            PanRightSmoother.trigger(
216                AbstractEngine::PanCurve[pan] * NotePanRight,
217                subfragmentRate
218            );
219    
220  #ifdef CONFIG_INTERPOLATE_VOLUME  #ifdef CONFIG_INTERPOLATE_VOLUME
221          // setup initial volume in synthesis parameters          // setup initial volume in synthesis parameters
# Line 430  namespace LinuxSampler { Line 441  namespace LinuxSampler {
441              processCCEvents(itCCEvent, iSubFragmentEnd);              processCCEvents(itCCEvent, iSubFragmentEnd);
442              uint8_t pan = MIDIPan;              uint8_t pan = MIDIPan;
443              if (pSignalUnitRack != NULL) pan = pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan);              if (pSignalUnitRack != NULL) pan = pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan);
               
             PanLeftSmoother.update(AbstractEngine::PanCurve[128 - pan]);  
             PanRightSmoother.update(AbstractEngine::PanCurve[pan]);  
444    
445              finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend;              PanLeftSmoother.update(AbstractEngine::PanCurve[128 - pan] * NotePanLeft);
446              float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render();              PanRightSmoother.update(AbstractEngine::PanCurve[pan]      * NotePanRight);
447    
448                finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend * NotePitch;
449    
450                float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render() * NoteVolumeSmoother.render();
451  #ifdef CONFIG_PROCESS_MUTED_CHANNELS  #ifdef CONFIG_PROCESS_MUTED_CHANNELS
452              if (pChannel->GetMute()) fFinalVolume = 0;              if (pChannel->GetMute()) fFinalVolume = 0;
453  #endif  #endif
# Line 512  namespace LinuxSampler { Line 524  namespace LinuxSampler {
524                      pSignalUnitRack->GetEndpointUnit()->CalculatePitch(finalSynthesisParameters.fFinalPitch);                      pSignalUnitRack->GetEndpointUnit()->CalculatePitch(finalSynthesisParameters.fFinalPitch);
525                                            
526              }              }
527                
528                fFinalCutoff    *= NoteCutoff;
529                fFinalResonance *= NoteResonance;
530    
531              // limit the pitch so we don't read outside the buffer              // limit the pitch so we don't read outside the buffer
532              finalSynthesisParameters.fFinalPitch = RTMath::Min(finalSynthesisParameters.fFinalPitch, float(1 << CONFIG_MAX_PITCH));              finalSynthesisParameters.fFinalPitch = RTMath::Min(finalSynthesisParameters.fFinalPitch, float(1 << CONFIG_MAX_PITCH));
533    
# Line 671  namespace LinuxSampler { Line 686  namespace LinuxSampler {
686      }      }
687    
688      /**      /**
689       * Process given list of MIDI note on, note off and sustain pedal events       * Process given list of MIDI note on, note off, sustain pedal events and
690       * for the given time.       * note synthesis parameter events for the given time.
691       *       *
692       * @param itEvent - iterator pointing to the next event to be processed       * @param itEvent - iterator pointing to the next event to be processed
693       * @param End     - youngest time stamp where processing should be stopped       * @param End     - youngest time stamp where processing should be stopped
# Line 681  namespace LinuxSampler { Line 696  namespace LinuxSampler {
696          for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) {          for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) {
697              // some voice types ignore note off              // some voice types ignore note off
698              if (!(Type & (Voice::type_one_shot | Voice::type_release_trigger | Voice::type_controller_triggered))) {              if (!(Type & (Voice::type_one_shot | Voice::type_release_trigger | Voice::type_controller_triggered))) {
699                  if (itEvent->Type == Event::type_release) {                  if (itEvent->Type == Event::type_release_key) {
700                      EnterReleaseStage();                      EnterReleaseStage();
701                  } else if (itEvent->Type == Event::type_cancel_release) {                  } else if (itEvent->Type == Event::type_cancel_release_key) {
702                      if (pSignalUnitRack == NULL) {                      if (pSignalUnitRack == NULL) {
703                          pEG1->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                          pEG1->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
704                          pEG2->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                          pEG2->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
# Line 692  namespace LinuxSampler { Line 707  namespace LinuxSampler {
707                      }                      }
708                  }                  }
709              }              }
710                // process stop-note events (caused by built-in instrument script function note_off())
711                if (itEvent->Type == Event::type_release_note && pNote &&
712                    pEngineChannel->pEngine->NoteByID( itEvent->Param.Note.ID ) == pNote)
713                {
714                    EnterReleaseStage();
715                }
716                // process synthesis parameter events (caused by built-in realt-time instrument script functions)
717                if (itEvent->Type == Event::type_note_synth_param && pNote &&
718                    pEngineChannel->pEngine->NoteByID( itEvent->Param.NoteSynthParam.NoteID ) == pNote)
719                {
720                    switch (itEvent->Param.NoteSynthParam.Type) {
721                        case Event::synth_param_volume:
722                            NoteVolumeSmoother.update(itEvent->Param.NoteSynthParam.AbsValue);
723                            break;
724                        case Event::synth_param_pitch:
725                            NotePitch = itEvent->Param.NoteSynthParam.AbsValue;
726                            break;
727                        case Event::synth_param_pan:
728                            NotePanLeft  = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 0 /*left*/);
729                            NotePanRight = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 1 /*right*/);
730                            break;
731                        case Event::synth_param_cutoff:
732                            NoteCutoff = itEvent->Param.NoteSynthParam.AbsValue;
733                            break;
734                        case Event::synth_param_resonance:
735                            NoteResonance = itEvent->Param.NoteSynthParam.AbsValue;
736                            break;
737                    }
738                }
739          }          }
740      }      }
741    

Legend:
Removed from v.2879  
changed lines
  Added in v.2938

  ViewVC Help
Powered by ViewVC