35 |
const int Voice::FILTER_UPDATE_MASK(CalculateFilterUpdateMask()); |
const int Voice::FILTER_UPDATE_MASK(CalculateFilterUpdateMask()); |
36 |
|
|
37 |
float Voice::CalculateFilterCutoffCoeff() { |
float Voice::CalculateFilterCutoffCoeff() { |
38 |
return log(CONFIG_FILTER_CUTOFF_MIN / CONFIG_FILTER_CUTOFF_MAX); |
return log(CONFIG_FILTER_CUTOFF_MAX / CONFIG_FILTER_CUTOFF_MIN); |
39 |
} |
} |
40 |
|
|
41 |
int Voice::CalculateFilterUpdateMask() { |
int Voice::CalculateFilterUpdateMask() { |
532 |
VCFResonanceCtrl.value = pEngineChannel->ControllerTable[VCFResonanceCtrl.controller]; |
VCFResonanceCtrl.value = pEngineChannel->ControllerTable[VCFResonanceCtrl.controller]; |
533 |
|
|
534 |
// calculate cutoff frequency |
// calculate cutoff frequency |
535 |
float cutoff = (!VCFCutoffCtrl.controller) |
float cutoff = pDimRgn->GetVelocityCutoff(itNoteOnEvent->Param.Note.Velocity); |
536 |
? exp((float) (127 - itNoteOnEvent->Param.Note.Velocity) * (float) pDimRgn->VCFVelocityScale * 6.2E-5f * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MAX |
if (pDimRgn->VCFKeyboardTracking) { |
537 |
: exp((float) VCFCutoffCtrl.value * 0.00787402f * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MAX; |
cutoff *= exp((itNoteOnEvent->Param.Note.Key - pDimRgn->VCFKeyboardTrackingBreakpoint) * 0.057762265f); // (ln(2) / 12) |
538 |
|
} |
539 |
|
CutoffBase = cutoff; |
540 |
|
|
541 |
|
int cvalue; |
542 |
|
if (VCFCutoffCtrl.controller) { |
543 |
|
cvalue = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller]; |
544 |
|
if (pDimRgn->VCFCutoffControllerInvert) cvalue = 127 - cvalue; |
545 |
|
if (cvalue < pDimRgn->VCFVelocityScale) cvalue = pDimRgn->VCFVelocityScale; |
546 |
|
} |
547 |
|
else { |
548 |
|
cvalue = pDimRgn->VCFCutoff; |
549 |
|
} |
550 |
|
cutoff *= float(cvalue) * 0.00787402f; // (1 / 127) |
551 |
|
if (cutoff > 1.0) cutoff = 1.0; |
552 |
|
cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN; |
553 |
|
|
554 |
// calculate resonance |
// calculate resonance |
555 |
float resonance = (float) VCFResonanceCtrl.value * 0.00787f; // 0.0..1.0 |
float resonance = (float) VCFResonanceCtrl.value * 0.00787f; // 0.0..1.0 |
856 |
// calculate the influence length of this event (in sample points) |
// calculate the influence length of this event (in sample points) |
857 |
uint end = (itNextCutoffEvent) ? itNextCutoffEvent->FragmentPos() : Samples; |
uint end = (itNextCutoffEvent) ? itNextCutoffEvent->FragmentPos() : Samples; |
858 |
|
|
859 |
cutoff = exp((float) itCutoffEvent->Param.CC.Value * 0.00787402f * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MAX - CONFIG_FILTER_CUTOFF_MIN; |
int cvalue = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller]; |
860 |
|
if (pDimRgn->VCFCutoffControllerInvert) cvalue = 127 - cvalue; |
861 |
|
if (cvalue < pDimRgn->VCFVelocityScale) cvalue = pDimRgn->VCFVelocityScale; |
862 |
|
cutoff = CutoffBase * float(cvalue) * 0.00787402f; // (1 / 127) |
863 |
|
if (cutoff > 1.0) cutoff = 1.0; |
864 |
|
cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN - CONFIG_FILTER_CUTOFF_MIN; |
865 |
|
|
866 |
// apply cutoff frequency to the cutoff parameter sequence |
// apply cutoff frequency to the cutoff parameter sequence |
867 |
for (uint i = itCutoffEvent->FragmentPos(); i < end; i++) { |
for (uint i = itCutoffEvent->FragmentPos(); i < end; i++) { |