488 |
|
|
489 |
} |
} |
490 |
|
|
491 |
|
float EndpointUnit::GetInfluence(::sfz::Array< ::sfz::optional<float> >& cc) { |
492 |
|
float f = 0; |
493 |
|
for (int i = 0; i < 128; i++) { |
494 |
|
if (cc[i]) { |
495 |
|
f += (pVoice->GetControllerValue(i) / 127.0f) * (*cc[i]); |
496 |
|
} |
497 |
|
} |
498 |
|
return f; |
499 |
|
} |
500 |
|
|
501 |
|
float EndpointUnit::GetInfluence(::sfz::Array< ::sfz::optional<int> >& cc) { |
502 |
|
float f = 0; |
503 |
|
for (int i = 0; i < 128; i++) { |
504 |
|
if (cc[i]) { |
505 |
|
f += (pVoice->GetControllerValue(i) / 127.0f) * (*cc[i]); |
506 |
|
} |
507 |
|
} |
508 |
|
return f; |
509 |
|
} |
510 |
|
|
511 |
SfzSignalUnitRack* const EndpointUnit::GetRack() { |
SfzSignalUnitRack* const EndpointUnit::GetRack() { |
512 |
return static_cast<SfzSignalUnitRack* const>(pRack); |
return static_cast<SfzSignalUnitRack* const>(pRack); |
513 |
} |
} |
514 |
|
|
515 |
void EndpointUnit::Trigger() { |
void EndpointUnit::Trigger() { |
516 |
|
uiDelayTrigger = (uint)GetInfluence(pVoice->pRegion->delay_samples_oncc); |
517 |
|
if (pVoice->pRegion->delay_samples) uiDelayTrigger += *pVoice->pRegion->delay_samples; |
518 |
|
|
519 |
|
if (pVoice->pRegion->delay) { |
520 |
|
/* here we use the device sample rate */ |
521 |
|
uiDelayTrigger += (uint)( (*pVoice->pRegion->delay) * pVoice->GetSampleRate() ); |
522 |
|
} |
523 |
|
|
524 |
|
if (pVoice->pRegion->delay_random) { |
525 |
|
float r = pVoice->GetEngine()->Random(); |
526 |
|
uiDelayTrigger += (uint)( r * (*pVoice->pRegion->delay_random) * pVoice->GetSampleRate() ); |
527 |
|
} |
528 |
|
|
529 |
|
uiDelayTrigger += (uint)(GetInfluence(pVoice->pRegion->delay_oncc) * pVoice->GetSampleRate()); |
530 |
|
|
531 |
float xfInVelCoeff = 1; |
float xfInVelCoeff = 1; |
532 |
|
|
533 |
if (pVoice->MIDIVelocity <= pVoice->pRegion->xfin_lovel) { |
if (pVoice->MIDIVelocity <= pVoice->pRegion->xfin_lovel) { |
599 |
} |
} |
600 |
|
|
601 |
bool EndpointUnit::Active() { |
bool EndpointUnit::Active() { |
602 |
|
if (pRack->isReleaseStageEntered() && uiDelayTrigger) { |
603 |
|
return false; // The key was released before the delay end, so the voice won't play at all. |
604 |
|
} |
605 |
|
|
606 |
if (GetRack()->suVolEG.Active()) return true; |
if (GetRack()->suVolEG.Active()) return true; |
607 |
|
|
608 |
bool b = false; |
bool b = false; |