153 |
}*/ // TODO: ^^^ |
}*/ // TODO: ^^^ |
154 |
} |
} |
155 |
|
|
|
void Voice::ProcessCutoffEvent(RTList<Event>::Iterator& itEvent) { |
|
|
int ccvalue = itEvent->Param.CC.Value; |
|
|
if (VCFCutoffCtrl.value == ccvalue) return; |
|
|
VCFCutoffCtrl.value = ccvalue; |
|
|
|
|
|
float cutoff = CutoffBase * RTMath::CentsToFreqRatioUnlimited( |
|
|
ccvalue / 127.0f * pRegion->cutoff_oncc[VCFCutoffCtrl.controller]); |
|
|
if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate; |
|
|
|
|
|
VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time |
|
|
fFinalCutoff = cutoff; |
|
|
} |
|
|
|
|
156 |
double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) { |
double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) { |
157 |
/*float crossfadeVolume; |
/*float crossfadeVolume; |
158 |
switch (pRegion->AttenuationController.type) { |
switch (pRegion->AttenuationController.type) { |
258 |
} |
} |
259 |
|
|
260 |
float Voice::CalculateFinalCutoff(float cutoffBase) { |
float Voice::CalculateFinalCutoff(float cutoffBase) { |
261 |
float cutoff; |
float cutoff = cutoffBase; |
|
if (VCFCutoffCtrl.controller) { |
|
|
int ccvalue = GetSfzEngineChannel()->ControllerTable[VCFCutoffCtrl.controller]; |
|
|
cutoff = CutoffBase * RTMath::CentsToFreqRatioUnlimited( |
|
|
ccvalue / 127.0f * pRegion->cutoff_oncc[VCFCutoffCtrl.controller]); |
|
|
} else { |
|
|
cutoff = cutoffBase; |
|
|
} |
|
262 |
if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate; |
if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate; |
263 |
return cutoff; |
return cutoff; |
264 |
} |
} |
265 |
|
|
|
uint8_t Voice::GetVCFCutoffCtrl() { |
|
|
// TODO: the sfz format allows several CC for the same |
|
|
// modulation destination. The Voice interface needs to be |
|
|
// changed to support that. |
|
|
if (pRegion->cutoff_cc) return pRegion->cutoff_cc; |
|
|
else if (pRegion->cutoff_chanaft) return 128; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
uint8_t Voice::GetVCFResonanceCtrl() { |
|
|
/*uint8_t ctrl; |
|
|
switch (pRegion->VCFResonanceController) { |
|
|
case ::gig::vcf_res_ctrl_genpurpose3: |
|
|
ctrl = 18; |
|
|
break; |
|
|
case ::gig::vcf_res_ctrl_genpurpose4: |
|
|
ctrl = 19; |
|
|
break; |
|
|
case ::gig::vcf_res_ctrl_genpurpose5: |
|
|
ctrl = 80; |
|
|
break; |
|
|
case ::gig::vcf_res_ctrl_genpurpose6: |
|
|
ctrl = 81; |
|
|
break; |
|
|
case ::gig::vcf_res_ctrl_none: |
|
|
default: |
|
|
ctrl = 0; |
|
|
} |
|
|
|
|
|
return ctrl;*/ // TODO: ^^^ |
|
|
return 0; |
|
|
} |
|
|
|
|
266 |
float Voice::GetReleaseTriggerAttenuation(float noteLength) { |
float Voice::GetReleaseTriggerAttenuation(float noteLength) { |
267 |
// pow(10, -rt_decay * noteLength / 20): |
// pow(10, -rt_decay * noteLength / 20): |
268 |
return expf(RgnInfo.ReleaseTriggerDecay * noteLength); |
return expf(RgnInfo.ReleaseTriggerDecay * noteLength); |