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() { |
249 |
} |
} |
250 |
if (pDimRgn->EG1ControllerInvert) eg1controllervalue = 127 - eg1controllervalue; |
if (pDimRgn->EG1ControllerInvert) eg1controllervalue = 127 - eg1controllervalue; |
251 |
|
|
252 |
// calculate influence of EG1 controller on EG1's parameters (TODO: needs to be fine tuned) |
// calculate influence of EG1 controller on EG1's parameters |
253 |
double eg1attack = (pDimRgn->EG1ControllerAttackInfluence) ? 0.0001 * (double) (1 << pDimRgn->EG1ControllerAttackInfluence) * eg1controllervalue : 0.0; |
// (eg1attack is different from the others) |
254 |
double eg1decay = (pDimRgn->EG1ControllerDecayInfluence) ? 0.0001 * (double) (1 << pDimRgn->EG1ControllerDecayInfluence) * eg1controllervalue : 0.0; |
double eg1attack = (pDimRgn->EG1ControllerAttackInfluence) ? |
255 |
double eg1release = (pDimRgn->EG1ControllerReleaseInfluence) ? 0.0001 * (double) (1 << pDimRgn->EG1ControllerReleaseInfluence) * eg1controllervalue : 0.0; |
1 + 0.031 * (double) (pDimRgn->EG1ControllerAttackInfluence == 1 ? |
256 |
|
1 : 1 << pDimRgn->EG1ControllerAttackInfluence) * eg1controllervalue : 1.0; |
257 |
|
double eg1decay = (pDimRgn->EG1ControllerDecayInfluence) ? 1 + 0.00775 * (double) (1 << pDimRgn->EG1ControllerDecayInfluence) * eg1controllervalue : 1.0; |
258 |
|
double eg1release = (pDimRgn->EG1ControllerReleaseInfluence) ? 1 + 0.00775 * (double) (1 << pDimRgn->EG1ControllerReleaseInfluence) * eg1controllervalue : 1.0; |
259 |
|
|
260 |
pEG1->Trigger(pDimRgn->EG1PreAttack, |
pEG1->Trigger(pDimRgn->EG1PreAttack, |
261 |
pDimRgn->EG1Attack + eg1attack, |
pDimRgn->EG1Attack * eg1attack, |
262 |
pDimRgn->EG1Hold, |
pDimRgn->EG1Hold, |
263 |
pSample->LoopStart, |
pSample->LoopStart, |
264 |
(pDimRgn->EG1Decay1 + eg1decay) * velrelease, |
pDimRgn->EG1Decay1 * eg1decay * velrelease, |
265 |
(pDimRgn->EG1Decay2 + eg1decay) * velrelease, |
pDimRgn->EG1Decay2 * eg1decay * velrelease, |
266 |
pDimRgn->EG1InfiniteSustain, |
pDimRgn->EG1InfiniteSustain, |
267 |
pDimRgn->EG1Sustain, |
pDimRgn->EG1Sustain, |
268 |
(pDimRgn->EG1Release + eg1release) * velrelease, |
pDimRgn->EG1Release * eg1release * velrelease, |
269 |
// the SSE synthesis implementation requires |
// the SSE synthesis implementation requires |
270 |
// the vca start to be 16 byte aligned |
// the vca start to be 16 byte aligned |
271 |
SYNTHESIS_MODE_GET_IMPLEMENTATION(SynthesisMode) ? |
SYNTHESIS_MODE_GET_IMPLEMENTATION(SynthesisMode) ? |
294 |
} |
} |
295 |
if (pDimRgn->EG2ControllerInvert) eg2controllervalue = 127 - eg2controllervalue; |
if (pDimRgn->EG2ControllerInvert) eg2controllervalue = 127 - eg2controllervalue; |
296 |
|
|
297 |
// calculate influence of EG2 controller on EG2's parameters (TODO: needs to be fine tuned) |
// calculate influence of EG2 controller on EG2's parameters |
298 |
double eg2attack = (pDimRgn->EG2ControllerAttackInfluence) ? 0.0001 * (double) (1 << pDimRgn->EG2ControllerAttackInfluence) * eg2controllervalue : 0.0; |
double eg2attack = (pDimRgn->EG2ControllerAttackInfluence) ? 1 + 0.00775 * (double) (1 << pDimRgn->EG2ControllerAttackInfluence) * eg2controllervalue : 1.0; |
299 |
double eg2decay = (pDimRgn->EG2ControllerDecayInfluence) ? 0.0001 * (double) (1 << pDimRgn->EG2ControllerDecayInfluence) * eg2controllervalue : 0.0; |
double eg2decay = (pDimRgn->EG2ControllerDecayInfluence) ? 1 + 0.00775 * (double) (1 << pDimRgn->EG2ControllerDecayInfluence) * eg2controllervalue : 1.0; |
300 |
double eg2release = (pDimRgn->EG2ControllerReleaseInfluence) ? 0.0001 * (double) (1 << pDimRgn->EG2ControllerReleaseInfluence) * eg2controllervalue : 0.0; |
double eg2release = (pDimRgn->EG2ControllerReleaseInfluence) ? 1 + 0.00775 * (double) (1 << pDimRgn->EG2ControllerReleaseInfluence) * eg2controllervalue : 1.0; |
301 |
|
|
302 |
pEG2->Trigger(pDimRgn->EG2PreAttack, |
pEG2->Trigger(pDimRgn->EG2PreAttack, |
303 |
pDimRgn->EG2Attack + eg2attack, |
pDimRgn->EG2Attack * eg2attack, |
304 |
false, |
false, |
305 |
pSample->LoopStart, |
pSample->LoopStart, |
306 |
(pDimRgn->EG2Decay1 + eg2decay) * velrelease, |
pDimRgn->EG2Decay1 * eg2decay * velrelease, |
307 |
(pDimRgn->EG2Decay2 + eg2decay) * velrelease, |
pDimRgn->EG2Decay2 * eg2decay * velrelease, |
308 |
pDimRgn->EG2InfiniteSustain, |
pDimRgn->EG2InfiniteSustain, |
309 |
pDimRgn->EG2Sustain, |
pDimRgn->EG2Sustain, |
310 |
(pDimRgn->EG2Release + eg2release) * velrelease, |
pDimRgn->EG2Release * eg2release * velrelease, |
311 |
Delay, |
Delay, |
312 |
velocityAttenuation); |
velocityAttenuation); |
313 |
} |
} |
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 |
591 |
|
|
592 |
// Reset the synthesis parameter matrix |
// Reset the synthesis parameter matrix |
593 |
|
|
594 |
|
#if CONFIG_PROCESS_MUTED_CHANNELS |
595 |
|
pEngine->ResetSynthesisParameters(Event::destination_vca, this->Volume * this->CrossfadeVolume * (pEngineChannel->GetMute() ? 0 : pEngineChannel->GlobalVolume)); |
596 |
|
#else |
597 |
pEngine->ResetSynthesisParameters(Event::destination_vca, this->Volume * this->CrossfadeVolume * pEngineChannel->GlobalVolume); |
pEngine->ResetSynthesisParameters(Event::destination_vca, this->Volume * this->CrossfadeVolume * pEngineChannel->GlobalVolume); |
598 |
|
#endif |
599 |
pEngine->ResetSynthesisParameters(Event::destination_vco, this->PitchBase); |
pEngine->ResetSynthesisParameters(Event::destination_vco, this->PitchBase); |
600 |
pEngine->ResetSynthesisParameters(Event::destination_vcfc, VCFCutoffCtrl.fvalue); |
pEngine->ResetSynthesisParameters(Event::destination_vcfc, VCFCutoffCtrl.fvalue); |
601 |
pEngine->ResetSynthesisParameters(Event::destination_vcfr, VCFResonanceCtrl.fvalue); |
pEngine->ResetSynthesisParameters(Event::destination_vcfr, VCFResonanceCtrl.fvalue); |
825 |
|
|
826 |
crossfadevolume = CrossfadeAttenuation(itVCAEvent->Param.CC.Value); |
crossfadevolume = CrossfadeAttenuation(itVCAEvent->Param.CC.Value); |
827 |
|
|
828 |
|
#if CONFIG_PROCESS_MUTED_CHANNELS |
829 |
|
float effective_volume = crossfadevolume * this->Volume * (pEngineChannel->GetMute() ? 0 : pEngineChannel->GlobalVolume); |
830 |
|
#else |
831 |
float effective_volume = crossfadevolume * this->Volume * pEngineChannel->GlobalVolume; |
float effective_volume = crossfadevolume * this->Volume * pEngineChannel->GlobalVolume; |
832 |
|
#endif |
833 |
|
|
834 |
// apply volume value to the volume parameter sequence |
// apply volume value to the volume parameter sequence |
835 |
for (uint i = itVCAEvent->FragmentPos(); i < end; i++) { |
for (uint i = itVCAEvent->FragmentPos(); i < end; i++) { |
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++) { |