/[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 617 by schoenebeck, Wed Jun 8 21:00:06 2005 UTC revision 630 by persson, Sat Jun 11 14:51:49 2005 UTC
# Line 269  namespace LinuxSampler { namespace gig { Line 269  namespace LinuxSampler { namespace gig {
269          pSample = pDimRgn->pSample; // sample won't change until the voice is finished          pSample = pDimRgn->pSample; // sample won't change until the voice is finished
270          if (!pSample || !pSample->SamplesTotal) return -1; // no need to continue if sample is silent          if (!pSample || !pSample->SamplesTotal) return -1; // no need to continue if sample is silent
271    
272            // calculate volume
273            const double velocityAttenuation = pDimRgn->GetVelocityAttenuation(itNoteOnEvent->Param.Note.Velocity);
274    
275            Volume = velocityAttenuation / 32768.0f; // we downscale by 32768 to convert from int16 value range to DSP value range (which is -1.0..1.0)
276    
277            Volume *= pDimRgn->SampleAttenuation;
278    
279            // the volume of release triggered samples depends on note length
280            if (ReleaseTriggerVoice) {
281                float noteLength = float(pEngine->FrameTime + Delay -
282                                         pEngineChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime) / pEngine->SampleRate;
283                float attenuation = 1 - 0.01053 * (256 >> pDimRgn->ReleaseTriggerDecay) * noteLength;
284                if (attenuation <= 0) return -1;
285                Volume *= attenuation;
286            }
287    
288          // select channel mode (mono or stereo)          // select channel mode (mono or stereo)
289          SYNTHESIS_MODE_SET_CHANNELS(SynthesisMode, pSample->Channels == 2);          SYNTHESIS_MODE_SET_CHANNELS(SynthesisMode, pSample->Channels == 2);
290    
# Line 333  namespace LinuxSampler { namespace gig { Line 349  namespace LinuxSampler { namespace gig {
349              this->PitchBend = RTMath::CentsToFreqRatio(((double) PitchBend / 8192.0) * 200.0); // pitchbend wheel +-2 semitones = 200 cents              this->PitchBend = RTMath::CentsToFreqRatio(((double) PitchBend / 8192.0) * 200.0); // pitchbend wheel +-2 semitones = 200 cents
350          }          }
351    
         const double velocityAttenuation = pDimRgn->GetVelocityAttenuation(itNoteOnEvent->Param.Note.Velocity);  
   
         Volume = velocityAttenuation / 32768.0f; // we downscale by 32768 to convert from int16 value range to DSP value range (which is -1.0..1.0)  
   
         Volume *= pDimRgn->SampleAttenuation;  
   
352          // 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
353          const double velrelease = 1 / pDimRgn->GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity);          const double velrelease = 1 / pDimRgn->GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity);
354    

Legend:
Removed from v.617  
changed lines
  Added in v.630

  ViewVC Help
Powered by ViewVC