/[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 3118 by schoenebeck, Fri Apr 21 13:33:03 2017 UTC revision 3214 by schoenebeck, Thu May 25 14:46:47 2017 UTC
# Line 129  namespace LinuxSampler { Line 129  namespace LinuxSampler {
129          AboutToTrigger();          AboutToTrigger();
130    
131          // calculate volume          // calculate volume
132          const double velocityAttenuation = GetVelocityAttenuation(itNoteOnEvent->Param.Note.Velocity);          const double velocityAttenuation = GetVelocityAttenuation(MIDIVelocity());
133          float volume = CalculateVolume(velocityAttenuation) * pKeyInfo->Volume;          float volume = CalculateVolume(velocityAttenuation) * pKeyInfo->Volume;
134          if (volume <= 0) return -1;          if (volume <= 0) return -1;
135    
# Line 139  namespace LinuxSampler { Line 139  namespace LinuxSampler {
139          SYNTHESIS_MODE_SET_BITDEPTH24(SynthesisMode, SmplInfo.BitDepth == 24);          SYNTHESIS_MODE_SET_BITDEPTH24(SynthesisMode, SmplInfo.BitDepth == 24);
140    
141          // get starting crossfade volume level          // get starting crossfade volume level
142          float crossfadeVolume = CalculateCrossfadeVolume(itNoteOnEvent->Param.Note.Velocity);          float crossfadeVolume = CalculateCrossfadeVolume(MIDIVelocity());
143    
144          VolumeLeft  = volume * pKeyInfo->PanLeft;          VolumeLeft  = volume * pKeyInfo->PanLeft;
145          VolumeRight = volume * pKeyInfo->PanRight;          VolumeRight = volume * pKeyInfo->PanRight;
# Line 147  namespace LinuxSampler { Line 147  namespace LinuxSampler {
147          // this rate is used for rather mellow volume fades          // this rate is used for rather mellow volume fades
148          const float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;          const float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE;
149          // this rate is used for very fast volume fades          // this rate is used for very fast volume fades
150          const float quickRampRate = RTMath::Min(subfragmentRate, GetEngine()->SampleRate * 0.001f /* 1ms */);          const float quickRampRate = RTMath::Min(subfragmentRate, GetEngine()->SampleRate * 0.001f /* approx. 13ms */);
151          CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate);          CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate);
152    
153          VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate);          VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate);
154          NoteVolumeSmoother.trigger(pNote ? pNote->Override.Volume : 1.f, quickRampRate);          NoteVolume.setCurrentValue(pNote ? pNote->Override.Volume : 1.f);
155            NoteVolume.setDefaultDuration(pNote ? pNote->Override.VolumeTime : DEFAULT_NOTE_VOLUME_TIME_S);
156    
157          // 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
158          long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize;          long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize;
# Line 191  namespace LinuxSampler { Line 192  namespace LinuxSampler {
192          }          }
193    
194          Pitch = CalculatePitchInfo(PitchBend);          Pitch = CalculatePitchInfo(PitchBend);
195          NotePitch = (pNote) ? pNote->Override.Pitch : 1.0f;          NotePitch.setCurrentValue(pNote ? pNote->Override.Pitch : 1.0f);
196            NotePitch.setDefaultDuration(pNote ? pNote->Override.PitchTime : DEFAULT_NOTE_PITCH_TIME_S);
197          NoteCutoff = (pNote) ? pNote->Override.Cutoff : 1.0f;          NoteCutoff = (pNote) ? pNote->Override.Cutoff : 1.0f;
198          NoteResonance = (pNote) ? pNote->Override.Resonance : 1.0f;          NoteResonance = (pNote) ? pNote->Override.Resonance : 1.0f;
199    
200          // 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
201          const double velrelease = 1 / GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity);          const double velrelease = 1 / GetVelocityRelease(MIDIVelocity());
202    
203          if (pSignalUnitRack == NULL) { // setup EG 1 (VCA EG)          if (pSignalUnitRack == NULL) { // setup EG 1 (VCA EG)
204              // get current value of EG1 controller              // get current value of EG1 controller
205              double eg1controllervalue = GetEG1ControllerValue(itNoteOnEvent->Param.Note.Velocity);              double eg1controllervalue = GetEG1ControllerValue(MIDIVelocity());
206    
207              // calculate influence of EG1 controller on EG1's parameters              // calculate influence of EG1 controller on EG1's parameters
208              EGInfo egInfo = CalculateEG1ControllerInfluence(eg1controllervalue);              EGInfo egInfo = CalculateEG1ControllerInfluence(eg1controllervalue);
# Line 211  namespace LinuxSampler { Line 213  namespace LinuxSampler {
213                  egInfo.Release *= pNote->Override.Release;                  egInfo.Release *= pNote->Override.Release;
214              }              }
215    
216              TriggerEG1(egInfo, velrelease, velocityAttenuation, GetEngine()->SampleRate, itNoteOnEvent->Param.Note.Velocity);              TriggerEG1(egInfo, velrelease, velocityAttenuation, GetEngine()->SampleRate, MIDIVelocity());
217          } else {          } else {
218              pSignalUnitRack->Trigger();              pSignalUnitRack->Trigger();
219          }          }
# Line 255  namespace LinuxSampler { Line 257  namespace LinuxSampler {
257              // setup EG 2 (VCF Cutoff EG)              // setup EG 2 (VCF Cutoff EG)
258              {              {
259                  // get current value of EG2 controller                  // get current value of EG2 controller
260                  double eg2controllervalue = GetEG2ControllerValue(itNoteOnEvent->Param.Note.Velocity);                  double eg2controllervalue = GetEG2ControllerValue(MIDIVelocity());
261    
262                  // calculate influence of EG2 controller on EG2's parameters                  // calculate influence of EG2 controller on EG2's parameters
263                  EGInfo egInfo = CalculateEG2ControllerInfluence(eg2controllervalue);                  EGInfo egInfo = CalculateEG2ControllerInfluence(eg2controllervalue);
264    
265                  TriggerEG2(egInfo, velrelease, velocityAttenuation, GetEngine()->SampleRate, itNoteOnEvent->Param.Note.Velocity);                  TriggerEG2(egInfo, velrelease, velocityAttenuation, GetEngine()->SampleRate, MIDIVelocity());
266              }              }
267    
268    
# Line 319  namespace LinuxSampler { Line 321  namespace LinuxSampler {
321              VCFResonanceCtrl.value = pEngineChannel->ControllerTable[VCFResonanceCtrl.controller];              VCFResonanceCtrl.value = pEngineChannel->ControllerTable[VCFResonanceCtrl.controller];
322    
323              // calculate cutoff frequency              // calculate cutoff frequency
324              CutoffBase = CalculateCutoffBase(itNoteOnEvent->Param.Note.Velocity);              CutoffBase = CalculateCutoffBase(MIDIVelocity());
325    
326              VCFCutoffCtrl.fvalue = CalculateFinalCutoff(CutoffBase);              VCFCutoffCtrl.fvalue = CalculateFinalCutoff(CutoffBase);
327    
# Line 456  namespace LinuxSampler { Line 458  namespace LinuxSampler {
458              PanLeftSmoother.update(AbstractEngine::PanCurve[128 - pan] * NotePanLeft);              PanLeftSmoother.update(AbstractEngine::PanCurve[128 - pan] * NotePanLeft);
459              PanRightSmoother.update(AbstractEngine::PanCurve[pan]      * NotePanRight);              PanRightSmoother.update(AbstractEngine::PanCurve[pan]      * NotePanRight);
460    
461              finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend * NotePitch;              finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend * NotePitch.render();
462    
463              float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render() * NoteVolumeSmoother.render();              float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render() * NoteVolume.render();
464  #ifdef CONFIG_PROCESS_MUTED_CHANNELS  #ifdef CONFIG_PROCESS_MUTED_CHANNELS
465              if (pChannel->GetMute()) fFinalVolume = 0;              if (pChannel->GetMute()) fFinalVolume = 0;
466  #endif  #endif
# Line 729  namespace LinuxSampler { Line 731  namespace LinuxSampler {
731              {              {
732                  EnterReleaseStage();                  EnterReleaseStage();
733              }              }
734                // process kill-note events (caused by built-in instrument script function fade_out())
735                if (itEvent->Type == Event::type_kill_note && pNote &&
736                    pEngineChannel->pEngine->NoteByID( itEvent->Param.Note.ID ) == pNote)
737                {
738                    Kill(itEvent);
739                }
740              // process synthesis parameter events (caused by built-in realt-time instrument script functions)              // process synthesis parameter events (caused by built-in realt-time instrument script functions)
741              if (itEvent->Type == Event::type_note_synth_param && pNote &&              if (itEvent->Type == Event::type_note_synth_param && pNote &&
742                  pEngineChannel->pEngine->NoteByID( itEvent->Param.NoteSynthParam.NoteID ) == pNote)                  pEngineChannel->pEngine->NoteByID( itEvent->Param.NoteSynthParam.NoteID ) == pNote)
743              {              {
744                  switch (itEvent->Param.NoteSynthParam.Type) {                  switch (itEvent->Param.NoteSynthParam.Type) {
745                      case Event::synth_param_volume:                      case Event::synth_param_volume:
746                          NoteVolumeSmoother.update(itEvent->Param.NoteSynthParam.AbsValue);                          NoteVolume.fadeTo(itEvent->Param.NoteSynthParam.AbsValue, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
747                            break;
748                        case Event::synth_param_volume_time:
749                            NoteVolume.setDefaultDuration(itEvent->Param.NoteSynthParam.AbsValue);
750                          break;                          break;
751                      case Event::synth_param_pitch:                      case Event::synth_param_pitch:
752                          NotePitch = itEvent->Param.NoteSynthParam.AbsValue;                          NotePitch.fadeTo(itEvent->Param.NoteSynthParam.AbsValue, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
753                            break;
754                        case Event::synth_param_pitch_time:
755                            NotePitch.setDefaultDuration(itEvent->Param.NoteSynthParam.AbsValue);
756                          break;                          break;
757                      case Event::synth_param_pan:                      case Event::synth_param_pan:
758                          NotePanLeft  = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 0 /*left*/);                          NotePanLeft  = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 0 /*left*/);

Legend:
Removed from v.3118  
changed lines
  Added in v.3214

  ViewVC Help
Powered by ViewVC