142 |
f = GetInfluence(egInfo.node[i].time_oncc); |
f = GetInfluence(egInfo.node[i].time_oncc); |
143 |
egInfo.node[i].time = std::min(egInfo.node[i].time + f, 100.0f); |
egInfo.node[i].time = std::min(egInfo.node[i].time + f, 100.0f); |
144 |
} |
} |
145 |
EG.trigger(egInfo, GetSampleRate(), pVoice->MIDIVelocity); |
EG.trigger(egInfo, GetSampleRate(), pVoice->MIDIVelocity()); |
146 |
} |
} |
147 |
|
|
148 |
|
|
151 |
depth = pRegion->pitcheg_depth + GetInfluence(pRegion->pitcheg_depth_oncc); |
depth = pRegion->pitcheg_depth + GetInfluence(pRegion->pitcheg_depth_oncc); |
152 |
|
|
153 |
// the length of the decay and release curves are dependent on the velocity |
// the length of the decay and release curves are dependent on the velocity |
154 |
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity); |
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity()); |
155 |
|
|
156 |
// set the delay trigger |
// set the delay trigger |
157 |
float delay = pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease; |
float delay = pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease; |
187 |
depth = pRegion->fileg_depth + GetInfluence(pRegion->fileg_depth_oncc); |
depth = pRegion->fileg_depth + GetInfluence(pRegion->fileg_depth_oncc); |
188 |
|
|
189 |
// the length of the decay and release curves are dependent on the velocity |
// the length of the decay and release curves are dependent on the velocity |
190 |
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity); |
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity()); |
191 |
|
|
192 |
// set the delay trigger |
// set the delay trigger |
193 |
float delay = pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease; |
float delay = pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease; |
222 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
223 |
|
|
224 |
// the length of the decay and release curves are dependent on the velocity |
// the length of the decay and release curves are dependent on the velocity |
225 |
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity); |
const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity()); |
226 |
|
|
227 |
// set the delay trigger |
// set the delay trigger |
228 |
float delay = pRegion->ampeg_delay + pRegion->ampeg_vel2delay * velrelease; |
float delay = pRegion->ampeg_delay + pRegion->ampeg_vel2delay * velrelease; |
255 |
|
|
256 |
LFOUnit::LFOUnit(SfzSignalUnitRack* rack) |
LFOUnit::LFOUnit(SfzSignalUnitRack* rack) |
257 |
: SfzSignalUnit(rack), pLfoInfo(NULL), pLFO(NULL), |
: SfzSignalUnit(rack), pLfoInfo(NULL), pLFO(NULL), |
258 |
suFadeEG(rack), suFreqOnCC(rack, this), suDepthOnCC(rack) |
suFadeEG(rack), suDepthOnCC(rack), suFreqOnCC(rack, this) |
259 |
{ } |
{ } |
260 |
|
|
261 |
LFOUnit::LFOUnit(const LFOUnit& Unit) |
LFOUnit::LFOUnit(const LFOUnit& Unit) |
262 |
: SfzSignalUnit(Unit), suFadeEG(static_cast<SfzSignalUnitRack*>(Unit.pRack)), |
: SfzSignalUnit(Unit), suFadeEG(static_cast<SfzSignalUnitRack*>(Unit.pRack)), |
263 |
suFreqOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack), this), |
suDepthOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack)), |
264 |
suDepthOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack)) |
suFreqOnCC(static_cast<SfzSignalUnitRack*>(Unit.pRack), this) |
265 |
{ |
{ |
266 |
Copy(Unit); |
Copy(Unit); |
267 |
} |
} |
328 |
void LFOv2Unit::Trigger() { |
void LFOv2Unit::Trigger() { |
329 |
LFOUnit::Trigger(); |
LFOUnit::Trigger(); |
330 |
|
|
331 |
if (pLfoInfo->wave < 0 || pLfoInfo->wave >= lfos.size()) pLFO = &lfo0; |
if (/*pLfoInfo->wave < 0 ||*/ pLfoInfo->wave >= lfos.size()) pLFO = &lfo0; |
332 |
else pLFO = lfos[pLfoInfo->wave]; |
else pLFO = lfos[pLfoInfo->wave]; |
333 |
|
|
334 |
pLFO->Trigger ( |
pLFO->Trigger ( |
483 |
|
|
484 |
|
|
485 |
EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack) |
EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack) |
486 |
: EndpointSignalUnit(rack), suXFInCC(rack), suXFOutCC(rack), suPanOnCC(rack), pitchVeltrackRatio(0) |
: EndpointSignalUnit(rack), pitchVeltrackRatio(0), suXFInCC(rack), suXFOutCC(rack), suPanOnCC(rack) |
487 |
{ |
{ |
488 |
|
|
489 |
} |
} |
530 |
|
|
531 |
float xfInVelCoeff = 1; |
float xfInVelCoeff = 1; |
532 |
|
|
533 |
if (pVoice->MIDIVelocity <= pVoice->pRegion->xfin_lovel) { |
if (pVoice->MIDIVelocity() <= pVoice->pRegion->xfin_lovel) { |
534 |
xfInVelCoeff = 0; |
xfInVelCoeff = 0; |
535 |
} else if (pVoice->MIDIVelocity >= pVoice->pRegion->xfin_hivel) { |
} else if (pVoice->MIDIVelocity() >= pVoice->pRegion->xfin_hivel) { |
536 |
xfInVelCoeff = 1; |
xfInVelCoeff = 1; |
537 |
} else { |
} else { |
538 |
float xfVelSize = pVoice->pRegion->xfin_hivel - pVoice->pRegion->xfin_lovel; |
float xfVelSize = pVoice->pRegion->xfin_hivel - pVoice->pRegion->xfin_lovel; |
539 |
float velPos = pVoice->MIDIVelocity - pVoice->pRegion->xfin_lovel; |
float velPos = pVoice->MIDIVelocity() - pVoice->pRegion->xfin_lovel; |
540 |
xfInVelCoeff = velPos / xfVelSize; |
xfInVelCoeff = velPos / xfVelSize; |
541 |
if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) { |
if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) { |
542 |
xfInVelCoeff = sin(xfInVelCoeff * M_PI / 2.0); |
xfInVelCoeff = sin(xfInVelCoeff * M_PI / 2.0); |
545 |
|
|
546 |
float xfOutVelCoeff = 1; |
float xfOutVelCoeff = 1; |
547 |
|
|
548 |
if (pVoice->MIDIVelocity >= pVoice->pRegion->xfout_hivel) { |
if (pVoice->MIDIVelocity() >= pVoice->pRegion->xfout_hivel) { |
549 |
if (pVoice->pRegion->xfout_lovel < 127 /* is set */) xfOutVelCoeff = 0; |
if (pVoice->pRegion->xfout_lovel < 127 /* is set */) xfOutVelCoeff = 0; |
550 |
} else if (pVoice->MIDIVelocity <= pVoice->pRegion->xfout_lovel) { |
} else if (pVoice->MIDIVelocity() <= pVoice->pRegion->xfout_lovel) { |
551 |
xfOutVelCoeff = 1; |
xfOutVelCoeff = 1; |
552 |
} else { |
} else { |
553 |
float xfVelSize = pVoice->pRegion->xfout_hivel - pVoice->pRegion->xfout_lovel; |
float xfVelSize = pVoice->pRegion->xfout_hivel - pVoice->pRegion->xfout_lovel; |
554 |
float velPos = pVoice->MIDIVelocity - pVoice->pRegion->xfout_lovel; |
float velPos = pVoice->MIDIVelocity() - pVoice->pRegion->xfout_lovel; |
555 |
xfOutVelCoeff = 1.0f - velPos / xfVelSize; |
xfOutVelCoeff = 1.0f - velPos / xfVelSize; |
556 |
if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) { |
if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) { |
557 |
xfOutVelCoeff = sin(xfOutVelCoeff * M_PI / 2.0); |
xfOutVelCoeff = sin(xfOutVelCoeff * M_PI / 2.0); |
560 |
|
|
561 |
float xfInKeyCoeff = 1; |
float xfInKeyCoeff = 1; |
562 |
|
|
563 |
if (pVoice->MIDIKey <= pVoice->pRegion->xfin_lokey) { |
if (pVoice->MIDIKey() <= pVoice->pRegion->xfin_lokey) { |
564 |
if (pVoice->pRegion->xfin_hikey > 0 /* is set */) xfInKeyCoeff = 0; |
if (pVoice->pRegion->xfin_hikey > 0 /* is set */) xfInKeyCoeff = 0; |
565 |
} else if (pVoice->MIDIKey >= pVoice->pRegion->xfin_hikey) { |
} else if (pVoice->MIDIKey() >= pVoice->pRegion->xfin_hikey) { |
566 |
xfInKeyCoeff = 1; |
xfInKeyCoeff = 1; |
567 |
} else { |
} else { |
568 |
float xfKeySize = pVoice->pRegion->xfin_hikey - pVoice->pRegion->xfin_lokey; |
float xfKeySize = pVoice->pRegion->xfin_hikey - pVoice->pRegion->xfin_lokey; |
569 |
float keyPos = pVoice->MIDIKey - pVoice->pRegion->xfin_lokey; |
float keyPos = pVoice->MIDIKey() - pVoice->pRegion->xfin_lokey; |
570 |
xfInKeyCoeff = keyPos / xfKeySize; |
xfInKeyCoeff = keyPos / xfKeySize; |
571 |
if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) { |
if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) { |
572 |
xfInKeyCoeff = sin(xfInKeyCoeff * M_PI / 2.0); |
xfInKeyCoeff = sin(xfInKeyCoeff * M_PI / 2.0); |
575 |
|
|
576 |
float xfOutKeyCoeff = 1; |
float xfOutKeyCoeff = 1; |
577 |
|
|
578 |
if (pVoice->MIDIKey >= pVoice->pRegion->xfout_hikey) { |
if (pVoice->MIDIKey() >= pVoice->pRegion->xfout_hikey) { |
579 |
if (pVoice->pRegion->xfout_lokey < 127 /* is set */) xfOutKeyCoeff = 0; |
if (pVoice->pRegion->xfout_lokey < 127 /* is set */) xfOutKeyCoeff = 0; |
580 |
} else if (pVoice->MIDIKey <= pVoice->pRegion->xfout_lokey) { |
} else if (pVoice->MIDIKey() <= pVoice->pRegion->xfout_lokey) { |
581 |
xfOutKeyCoeff = 1; |
xfOutKeyCoeff = 1; |
582 |
} else { |
} else { |
583 |
float xfKeySize = pVoice->pRegion->xfout_hikey - pVoice->pRegion->xfout_lokey; |
float xfKeySize = pVoice->pRegion->xfout_hikey - pVoice->pRegion->xfout_lokey; |
584 |
float keyPos = pVoice->MIDIKey - pVoice->pRegion->xfout_lokey; |
float keyPos = pVoice->MIDIKey() - pVoice->pRegion->xfout_lokey; |
585 |
xfOutKeyCoeff = 1.0f - keyPos / xfKeySize; |
xfOutKeyCoeff = 1.0f - keyPos / xfKeySize; |
586 |
if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) { |
if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) { |
587 |
xfOutKeyCoeff = sin(xfOutKeyCoeff * M_PI / 2.0); |
xfOutKeyCoeff = sin(xfOutKeyCoeff * M_PI / 2.0); |
595 |
|
|
596 |
suPanOnCC.SetCCs(pVoice->pRegion->pan_oncc); |
suPanOnCC.SetCCs(pVoice->pRegion->pan_oncc); |
597 |
|
|
598 |
pitchVeltrackRatio = RTMath::CentsToFreqRatioUnlimited((pVoice->MIDIVelocity / 127.0f) * pVoice->pRegion->pitch_veltrack); |
pitchVeltrackRatio = RTMath::CentsToFreqRatioUnlimited((pVoice->MIDIVelocity() / 127.0f) * pVoice->pRegion->pitch_veltrack); |
599 |
} |
} |
600 |
|
|
601 |
bool EndpointUnit::Active() { |
bool EndpointUnit::Active() { |
771 |
pan += lfo->GetLevel() * (lfo->pLfoInfo->pan + f); |
pan += lfo->GetLevel() * (lfo->pLfoInfo->pan + f); |
772 |
} |
} |
773 |
|
|
|
if(pan < -100) return -100; |
|
|
if(pan > 100) return 100; |
|
|
|
|
774 |
return pan; |
return pan; |
775 |
} |
} |
776 |
|
|
777 |
|
|
778 |
SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) |
SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) |
779 |
: SignalUnitRack(MaxUnitCount), EqUnitSupport(this, voice), pVoice(voice), |
: SignalUnitRack(MaxUnitCount), EqUnitSupport(this, voice), |
780 |
suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), |
suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), |
781 |
|
suAmpLFO(this), suPitchLFO(this), suFilLFO(this), |
782 |
|
suVolOnCC(this), suPitchOnCC(this), suCutoffOnCC(this), suResOnCC(this), |
783 |
EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount), |
EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount), |
784 |
resEGs(maxEgCount), panEGs(maxEgCount), eqEGs(maxEgCount), |
resEGs(maxEgCount), panEGs(maxEgCount), eqEGs(maxEgCount), |
|
suVolOnCC(this), suPitchOnCC(this), suCutoffOnCC(this), suResOnCC(this), |
|
|
suAmpLFO(this), suPitchLFO(this), suFilLFO(this), |
|
785 |
LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount), |
LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount), |
786 |
filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount), eqLFOs(maxLfoCount) |
filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount), eqLFOs(maxLfoCount), |
787 |
|
pVoice(voice) |
788 |
{ |
{ |
789 |
suEndpoint.pVoice = suEndpoint.suXFInCC.pVoice = suEndpoint.suXFOutCC.pVoice = suEndpoint.suPanOnCC.pVoice = voice; |
suEndpoint.pVoice = suEndpoint.suXFInCC.pVoice = suEndpoint.suXFOutCC.pVoice = suEndpoint.suPanOnCC.pVoice = voice; |
790 |
suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; |
suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; |
1123 |
volEGs[i]->EG.enterFadeOutStage(); |
volEGs[i]->EG.enterFadeOutStage(); |
1124 |
} |
} |
1125 |
} |
} |
1126 |
|
|
1127 |
|
void SfzSignalUnitRack::EnterFadeOutStage(int maxFadeOutSteps) { |
1128 |
|
suVolEG.EG.enterFadeOutStage(maxFadeOutSteps); |
1129 |
|
for (int i = 0; i < volEGs.size(); i++) { |
1130 |
|
volEGs[i]->EG.enterFadeOutStage(maxFadeOutSteps); |
1131 |
|
} |
1132 |
|
} |
1133 |
|
|
1134 |
void SfzSignalUnitRack::Reset() { |
void SfzSignalUnitRack::Reset() { |
1135 |
EqUnitSupport::ResetUnits(); |
EqUnitSupport::ResetUnits(); |
1136 |
|
|
1170 |
LFOs[i]->ResetUnits(); // class EqUnitSupport |
LFOs[i]->ResetUnits(); // class EqUnitSupport |
1171 |
} |
} |
1172 |
} |
} |
1173 |
|
|
1174 |
|
void SfzSignalUnitRack::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) { |
1175 |
|
suVolEG.EG.CalculateFadeOutCoeff(FadeOutTime, SampleRate); |
1176 |
|
for (int i = 0; i < EGs.capacity(); i++) { |
1177 |
|
EGs[i]->EG.CalculateFadeOutCoeff(FadeOutTime, SampleRate); |
1178 |
|
} |
1179 |
|
} |
1180 |
|
|
1181 |
void SfzSignalUnitRack::UpdateEqSettings(EqSupport* pEqSupport) { |
void SfzSignalUnitRack::UpdateEqSettings(EqSupport* pEqSupport) { |
1182 |
if (!pEqSupport->HasSupport()) return; |
if (!pEqSupport->HasSupport()) return; |
1199 |
float bw2 = (suEq2BwOnCC.Active() ? suEq2BwOnCC.GetLevel() : 0) + pRegion->eq2_bw; |
float bw2 = (suEq2BwOnCC.Active() ? suEq2BwOnCC.GetLevel() : 0) + pRegion->eq2_bw; |
1200 |
float bw3 = (suEq3BwOnCC.Active() ? suEq3BwOnCC.GetLevel() : 0) + pRegion->eq3_bw; |
float bw3 = (suEq3BwOnCC.Active() ? suEq3BwOnCC.GetLevel() : 0) + pRegion->eq3_bw; |
1201 |
|
|
1202 |
const float vel = pVoice->MIDIVelocity / 127.0f; |
const float vel = pVoice->MIDIVelocity() / 127.0f; |
1203 |
|
|
1204 |
dB1 += pRegion->eq1_vel2gain * vel; |
dB1 += pRegion->eq1_vel2gain * vel; |
1205 |
dB2 += pRegion->eq2_vel2gain * vel; |
dB2 += pRegion->eq2_vel2gain * vel; |