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 |
|
|
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 |
|
|