34 |
typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoice; |
typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoice; |
35 |
Voice::Voice(): SignalRack(this), SfzVoice(&SignalRack) { |
Voice::Voice(): SignalRack(this), SfzVoice(&SignalRack) { |
36 |
pEngine = NULL; |
pEngine = NULL; |
37 |
|
bEqSupport = true; |
38 |
} |
} |
39 |
|
|
40 |
Voice::~Voice() { |
Voice::~Voice() { |
75 |
ri.Pan = int(pRegion->pan * 0.63); // convert from -100..100 to -64..63 |
ri.Pan = int(pRegion->pan * 0.63); // convert from -100..100 to -64..63 |
76 |
ri.SampleStartOffset = pRegion->offset ? *(pRegion->offset) : 0; |
ri.SampleStartOffset = pRegion->offset ? *(pRegion->offset) : 0; |
77 |
|
|
|
ri.EG2PreAttack = pRegion->fileg_start * 10; |
|
|
ri.EG2Attack = pRegion->fileg_attack; |
|
|
//ri.EG2Hold = pRegion->fileg_hold; // TODO: |
|
|
ri.EG2Decay1 = pRegion->fileg_decay; |
|
|
ri.EG2Decay2 = pRegion->fileg_decay; |
|
|
ri.EG2Sustain = pRegion->fileg_sustain * 10; |
|
|
ri.EG2InfiniteSustain = true; |
|
|
ri.EG2Release = pRegion->fileg_release; |
|
|
|
|
|
ri.EG3Attack = pRegion->pitcheg_attack; |
|
|
ri.EG3Depth = 0; // TODO: |
|
78 |
ri.VCFEnabled = pRegion->cutoff; |
ri.VCFEnabled = pRegion->cutoff; |
79 |
switch (pRegion->fil_type) { |
switch (pRegion->fil_type) { |
80 |
case ::sfz::LPF_1P: |
case ::sfz::LPF_1P: |
154 |
}*/ // TODO: ^^^ |
}*/ // TODO: ^^^ |
155 |
} |
} |
156 |
|
|
|
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; |
|
|
} |
|
|
|
|
157 |
double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) { |
double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) { |
158 |
/*float crossfadeVolume; |
/*float crossfadeVolume; |
159 |
switch (pRegion->AttenuationController.type) { |
switch (pRegion->AttenuationController.type) { |
259 |
} |
} |
260 |
|
|
261 |
float Voice::CalculateFinalCutoff(float cutoffBase) { |
float Voice::CalculateFinalCutoff(float cutoffBase) { |
262 |
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; |
|
|
} |
|
263 |
if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate; |
if (cutoff > 0.49 * pEngine->SampleRate) cutoff = 0.49 * pEngine->SampleRate; |
264 |
return cutoff; |
return cutoff; |
265 |
} |
} |
266 |
|
|
|
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; |
|
|
} |
|
|
|
|
267 |
float Voice::GetReleaseTriggerAttenuation(float noteLength) { |
float Voice::GetReleaseTriggerAttenuation(float noteLength) { |
268 |
// pow(10, -rt_decay * noteLength / 20): |
// pow(10, -rt_decay * noteLength / 20): |
269 |
return expf(RgnInfo.ReleaseTriggerDecay * noteLength); |
return expf(RgnInfo.ReleaseTriggerDecay * noteLength); |