494 |
if (VCFCutoffCtrl.controller) { |
if (VCFCutoffCtrl.controller) { |
495 |
cvalue = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller]; |
cvalue = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller]; |
496 |
if (pDimRgn->VCFCutoffControllerInvert) cvalue = 127 - cvalue; |
if (pDimRgn->VCFCutoffControllerInvert) cvalue = 127 - cvalue; |
497 |
|
// VCFVelocityScale in this case means Minimum cutoff |
498 |
if (cvalue < pDimRgn->VCFVelocityScale) cvalue = pDimRgn->VCFVelocityScale; |
if (cvalue < pDimRgn->VCFVelocityScale) cvalue = pDimRgn->VCFVelocityScale; |
499 |
} |
} |
500 |
else { |
else { |
502 |
} |
} |
503 |
cutoff *= float(cvalue) * 0.00787402f; // (1 / 127) |
cutoff *= float(cvalue) * 0.00787402f; // (1 / 127) |
504 |
if (cutoff > 1.0) cutoff = 1.0; |
if (cutoff > 1.0) cutoff = 1.0; |
505 |
cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN; |
cutoff = (cutoff < 0.5 ? cutoff * 4826 - 1 : cutoff * 5715 - 449); |
506 |
|
if (cutoff < 1.0) cutoff = 1.0; |
507 |
|
|
508 |
// calculate resonance |
// calculate resonance |
509 |
float resonance = (float) VCFResonanceCtrl.value * 0.00787f; // 0.0..1.0 |
float resonance = (float) (VCFResonanceCtrl.controller ? VCFResonanceCtrl.value : pDimRgn->VCFResonance) * 0.00787f; // 0.0..1.0 |
|
if (pDimRgn->VCFKeyboardTracking) { |
|
|
resonance += (float) (itNoteOnEvent->Param.Note.Key - pDimRgn->VCFKeyboardTrackingBreakpoint) * 0.00787f; |
|
|
} |
|
|
Constrain(resonance, 0.0, 1.0); // correct resonance if outside allowed value range (0.0..1.0) |
|
510 |
|
|
511 |
VCFCutoffCtrl.fvalue = cutoff - CONFIG_FILTER_CUTOFF_MIN; |
VCFCutoffCtrl.fvalue = cutoff - 1.0; |
512 |
VCFResonanceCtrl.fvalue = resonance; |
VCFResonanceCtrl.fvalue = resonance; |
513 |
} |
} |
514 |
else { |
else { |
712 |
if (ccvalue < pDimRgn->VCFVelocityScale) ccvalue = pDimRgn->VCFVelocityScale; |
if (ccvalue < pDimRgn->VCFVelocityScale) ccvalue = pDimRgn->VCFVelocityScale; |
713 |
float cutoff = CutoffBase * float(ccvalue) * 0.00787402f; // (1 / 127) |
float cutoff = CutoffBase * float(ccvalue) * 0.00787402f; // (1 / 127) |
714 |
if (cutoff > 1.0) cutoff = 1.0; |
if (cutoff > 1.0) cutoff = 1.0; |
715 |
cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN - CONFIG_FILTER_CUTOFF_MIN; |
cutoff = (cutoff < 0.5 ? cutoff * 4826 - 1 : cutoff * 5715 - 449); |
716 |
VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time |
if (cutoff < 1.0) cutoff = 1.0; |
717 |
|
|
718 |
|
VCFCutoffCtrl.fvalue = cutoff - 1.0; // needed for initialization of fFinalCutoff next time |
719 |
fFinalCutoff = cutoff; |
fFinalCutoff = cutoff; |
720 |
} |
} |
721 |
|
|
750 |
while (itNoteEvent && itNoteEvent->FragmentPos() <= Skip) ++itNoteEvent; |
while (itNoteEvent && itNoteEvent->FragmentPos() <= Skip) ++itNoteEvent; |
751 |
} |
} |
752 |
|
|
753 |
|
uint killPos; |
754 |
|
if (itKillEvent) killPos = RTMath::Min(itKillEvent->FragmentPos(), pEngine->MaxFadeOutPos); |
755 |
|
|
756 |
uint i = Skip; |
uint i = Skip; |
757 |
while (i < Samples) { |
while (i < Samples) { |
758 |
int iSubFragmentEnd = RTMath::Min(i + CONFIG_DEFAULT_SUBFRAGMENT_SIZE, Samples); |
int iSubFragmentEnd = RTMath::Min(i + CONFIG_DEFAULT_SUBFRAGMENT_SIZE, Samples); |
773 |
// process transition events (note on, note off & sustain pedal) |
// process transition events (note on, note off & sustain pedal) |
774 |
processTransitionEvents(itNoteEvent, iSubFragmentEnd); |
processTransitionEvents(itNoteEvent, iSubFragmentEnd); |
775 |
|
|
776 |
|
// if the voice was killed in this subfragment switch EG1 to fade out stage |
777 |
|
if (itKillEvent && killPos <= iSubFragmentEnd) { |
778 |
|
EG1.enterFadeOutStage(); |
779 |
|
itKillEvent = Pool<Event>::Iterator(); |
780 |
|
} |
781 |
|
|
782 |
// process envelope generators |
// process envelope generators |
783 |
switch (EG1.getSegmentType()) { |
switch (EG1.getSegmentType()) { |
784 |
case EGADSR::segment_lin: |
case EGADSR::segment_lin: |
811 |
|
|
812 |
// if filter enabled then update filter coefficients |
// if filter enabled then update filter coefficients |
813 |
if (SYNTHESIS_MODE_GET_FILTER(SynthesisMode)) { |
if (SYNTHESIS_MODE_GET_FILTER(SynthesisMode)) { |
814 |
finalSynthesisParameters.filterLeft.SetParameters(fFinalCutoff, fFinalResonance, pEngine->SampleRate); |
finalSynthesisParameters.filterLeft.SetParameters(fFinalCutoff + 1.0, fFinalResonance, pEngine->SampleRate); |
815 |
finalSynthesisParameters.filterRight.SetParameters(fFinalCutoff, fFinalResonance, pEngine->SampleRate); |
finalSynthesisParameters.filterRight.SetParameters(fFinalCutoff + 1.0, fFinalResonance, pEngine->SampleRate); |
816 |
} |
} |
817 |
|
|
818 |
// do we need resampling? |
// do we need resampling? |