293 |
} |
} |
294 |
|
|
295 |
void LFOUnit::ValueChanged(CCSignalUnit* pUnit) { |
void LFOUnit::ValueChanged(CCSignalUnit* pUnit) { |
296 |
|
if (pLFO == NULL) return; |
297 |
pLFO->SetFrequency(std::max(0.0f, suFreqOnCC.GetLevel() + pLfoInfo->freq), GetSampleRate()); |
pLFO->SetFrequency(std::max(0.0f, suFreqOnCC.GetLevel() + pLfoInfo->freq), GetSampleRate()); |
298 |
} |
} |
299 |
|
|
343 |
} |
} |
344 |
|
|
345 |
void AmpLFOUnit::Trigger() { |
void AmpLFOUnit::Trigger() { |
346 |
|
bActive = true; |
347 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
348 |
pLfoInfo->delay = pRegion->amplfo_delay + GetInfluence(pRegion->amplfo_delay_oncc); |
pLfoInfo->delay = pRegion->amplfo_delay + GetInfluence(pRegion->amplfo_delay_oncc); |
349 |
pLfoInfo->freq = pRegion->amplfo_freq; |
pLfoInfo->freq = pRegion->amplfo_freq; |
350 |
pLfoInfo->fade = pRegion->amplfo_fade + GetInfluence(pRegion->amplfo_fade_oncc); |
pLfoInfo->fade = pRegion->amplfo_fade + GetInfluence(pRegion->amplfo_fade_oncc); |
351 |
pLfoInfo->volume = pRegion->amplfo_depth; |
pLfoInfo->volume = pRegion->amplfo_depth; |
352 |
|
|
353 |
|
if (pLfoInfo->freq <= 0) { |
354 |
|
if (!pRegion->amplfo_freqcc.empty()) pLfoInfo->freq = 0; |
355 |
|
else bActive = false; |
356 |
|
} |
357 |
|
|
358 |
LFOv1Unit::Trigger(); |
LFOv1Unit::Trigger(); |
359 |
} |
} |
360 |
|
|
361 |
void PitchLFOUnit::Trigger() { |
void PitchLFOUnit::Trigger() { |
362 |
|
bActive = true; |
363 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
364 |
pLfoInfo->delay = pRegion->pitchlfo_delay + GetInfluence(pRegion->pitchlfo_delay_oncc); |
pLfoInfo->delay = pRegion->pitchlfo_delay + GetInfluence(pRegion->pitchlfo_delay_oncc); |
365 |
pLfoInfo->freq = pRegion->pitchlfo_freq; |
pLfoInfo->freq = pRegion->pitchlfo_freq; |
366 |
pLfoInfo->fade = pRegion->pitchlfo_fade + GetInfluence(pRegion->pitchlfo_fade_oncc); |
pLfoInfo->fade = pRegion->pitchlfo_fade + GetInfluence(pRegion->pitchlfo_fade_oncc); |
367 |
pLfoInfo->pitch = pRegion->pitchlfo_depth; |
pLfoInfo->pitch = pRegion->pitchlfo_depth; |
368 |
|
|
369 |
|
if (pLfoInfo->freq <= 0) { |
370 |
|
if (!pRegion->pitchlfo_freqcc.empty()) pLfoInfo->freq = 0; |
371 |
|
else bActive = false; |
372 |
|
} |
373 |
|
|
374 |
LFOv1Unit::Trigger(); |
LFOv1Unit::Trigger(); |
375 |
} |
} |
376 |
|
|
377 |
void FilLFOUnit::Trigger() { |
void FilLFOUnit::Trigger() { |
378 |
|
bActive = true; |
379 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
380 |
pLfoInfo->delay = pRegion->fillfo_delay + GetInfluence(pRegion->fillfo_delay_oncc); |
pLfoInfo->delay = pRegion->fillfo_delay + GetInfluence(pRegion->fillfo_delay_oncc); |
381 |
pLfoInfo->freq = pRegion->fillfo_freq; |
pLfoInfo->freq = pRegion->fillfo_freq; |
382 |
pLfoInfo->fade = pRegion->fillfo_fade + GetInfluence(pRegion->fillfo_fade_oncc); |
pLfoInfo->fade = pRegion->fillfo_fade + GetInfluence(pRegion->fillfo_fade_oncc); |
383 |
pLfoInfo->cutoff = pRegion->fillfo_depth; |
pLfoInfo->cutoff = pRegion->fillfo_depth; |
384 |
|
|
385 |
|
if (pLfoInfo->freq <= 0) { |
386 |
|
if (!pRegion->fillfo_freqcc.empty()) pLfoInfo->freq = 0; |
387 |
|
else bActive = false; |
388 |
|
} |
389 |
|
|
390 |
LFOv1Unit::Trigger(); |
LFOv1Unit::Trigger(); |
391 |
} |
} |
392 |
|
|
603 |
} |
} |
604 |
|
|
605 |
float EndpointUnit::GetFilterCutoff() { |
float EndpointUnit::GetFilterCutoff() { |
606 |
float val; |
float val = GetRack()->suCutoffOnCC.Active() ? RTMath::CentsToFreqRatioUnlimited(GetRack()->suCutoffOnCC.GetLevel()) : 1; |
607 |
|
|
608 |
FilLFOUnit* u = &(GetRack()->suFilLFO); |
FilLFOUnit* u = &(GetRack()->suFilLFO); |
609 |
CCSignalUnit* u1 = &(GetRack()->suFilLFO.suDepthOnCC); |
CCSignalUnit* u1 = &(GetRack()->suFilLFO.suDepthOnCC); |
610 |
float f = u1->Active() ? u1->GetLevel() : 0; |
float f = u1->Active() ? u1->GetLevel() : 0; |
611 |
val = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * (u->pLfoInfo->cutoff + f)) : 1; |
val *= u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * (u->pLfoInfo->cutoff + f)) : 1; |
612 |
|
|
613 |
FilEGUnit* u2 = &(GetRack()->suFilEG); |
FilEGUnit* u2 = &(GetRack()->suFilEG); |
614 |
val *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * u2->depth) : 1; |
val *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * u2->depth) : 1; |
635 |
} |
} |
636 |
|
|
637 |
float EndpointUnit::CalculateFilterCutoff(float cutoff) { |
float EndpointUnit::CalculateFilterCutoff(float cutoff) { |
638 |
cutoff *= GetFilterCutoff(); |
cutoff *= GetFilterCutoff(); |
639 |
float maxCutoff = 0.49 * pVoice->GetSampleRate(); |
float maxCutoff = 0.49 * pVoice->GetSampleRate(); |
640 |
return cutoff > maxCutoff ? maxCutoff : cutoff; |
return cutoff > maxCutoff ? maxCutoff : cutoff; |
641 |
} |
} |
642 |
|
|
643 |
float EndpointUnit::GetPitch() { |
float EndpointUnit::GetPitch() { |
670 |
} |
} |
671 |
|
|
672 |
float EndpointUnit::GetResonance() { |
float EndpointUnit::GetResonance() { |
673 |
float val = 0; |
float val = GetRack()->suResOnCC.Active() ? GetRack()->suResOnCC.GetLevel() : 0; |
674 |
|
|
675 |
for (int i = 0; i < GetRack()->resEGs.size(); i++) { |
for (int i = 0; i < GetRack()->resEGs.size(); i++) { |
676 |
EGv2Unit* eg = GetRack()->resEGs[i]; |
EGv2Unit* eg = GetRack()->resEGs[i]; |
726 |
|
|
727 |
SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) |
SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) |
728 |
: SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), |
: SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), |
729 |
EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount), resEGs(maxEgCount), panEGs(maxEgCount), suVolOnCC(this), |
EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount), resEGs(maxEgCount), panEGs(maxEgCount), |
730 |
|
suVolOnCC(this), suCutoffOnCC(this), suResOnCC(this), |
731 |
suAmpLFO(this), suPitchLFO(this), suFilLFO(this), |
suAmpLFO(this), suPitchLFO(this), suFilLFO(this), |
732 |
LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount), |
LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount), |
733 |
filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount) |
filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount) |
734 |
{ |
{ |
735 |
suEndpoint.pVoice = suEndpoint.suXFInCC.pVoice = suEndpoint.suXFOutCC.pVoice = suEndpoint.suPanOnCC.pVoice = voice; |
suEndpoint.pVoice = suEndpoint.suXFInCC.pVoice = suEndpoint.suXFOutCC.pVoice = suEndpoint.suPanOnCC.pVoice = voice; |
736 |
suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; |
suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; |
737 |
suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = suVolOnCC.pVoice = voice; |
suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = suVolOnCC.pVoice = suCutoffOnCC.pVoice = suResOnCC.pVoice = voice; |
738 |
suPitchLFO.suDepthOnCC.pVoice = suPitchLFO.suFadeEG.pVoice = suPitchLFO.suFreqOnCC.pVoice = voice; |
suPitchLFO.suDepthOnCC.pVoice = suPitchLFO.suFadeEG.pVoice = suPitchLFO.suFreqOnCC.pVoice = voice; |
739 |
suFilLFO.suFadeEG.pVoice = suFilLFO.suDepthOnCC.pVoice = suFilLFO.suFreqOnCC.pVoice = voice; |
suFilLFO.suFadeEG.pVoice = suFilLFO.suDepthOnCC.pVoice = suFilLFO.suFreqOnCC.pVoice = voice; |
740 |
suAmpLFO.suFadeEG.pVoice = suAmpLFO.suDepthOnCC.pVoice = suAmpLFO.suFreqOnCC.pVoice = voice; |
suAmpLFO.suFadeEG.pVoice = suAmpLFO.suDepthOnCC.pVoice = suAmpLFO.suFreqOnCC.pVoice = voice; |
780 |
Pool<Smoother>* pSmootherPool = pVoice->pEngine->pSmootherPool; |
Pool<Smoother>* pSmootherPool = pVoice->pEngine->pSmootherPool; |
781 |
|
|
782 |
suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
783 |
|
suCutoffOnCC.InitCCList(pCCPool, pSmootherPool); |
784 |
|
suResOnCC.InitCCList(pCCPool, pSmootherPool); |
785 |
suEndpoint.suXFInCC.InitCCList(pCCPool, pSmootherPool); |
suEndpoint.suXFInCC.InitCCList(pCCPool, pSmootherPool); |
786 |
suEndpoint.suXFOutCC.InitCCList(pCCPool, pSmootherPool); |
suEndpoint.suXFOutCC.InitCCList(pCCPool, pSmootherPool); |
787 |
suEndpoint.suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
suEndpoint.suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
831 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
832 |
|
|
833 |
suVolOnCC.SetCCs(pRegion->volume_oncc); |
suVolOnCC.SetCCs(pRegion->volume_oncc); |
834 |
|
suCutoffOnCC.SetCCs(pRegion->cutoff_oncc); |
835 |
|
suResOnCC.SetCCs(pRegion->resonance_oncc); |
836 |
|
|
837 |
for (int i = 0; i < pRegion->eg.size(); i++) { |
for (int i = 0; i < pRegion->eg.size(); i++) { |
838 |
if (pRegion->eg[i].node.size() == 0) continue; |
if (pRegion->eg[i].node.size() == 0) continue; |
884 |
|
|
885 |
// LFO |
// LFO |
886 |
for (int i = 0; i < pRegion->lfos.size(); i++) { |
for (int i = 0; i < pRegion->lfos.size(); i++) { |
887 |
if (pRegion->lfos[i].freq == -1) continue; // Not initialized |
if (pRegion->lfos[i].freq <= 0) { |
888 |
|
if (pRegion->lfos[i].freq_oncc.empty()) continue; // Not initialized |
889 |
|
else pRegion->lfos[i].freq = 0; |
890 |
|
} |
891 |
|
|
892 |
if(LFOs.size() < LFOs.capacity()) { |
if(LFOs.size() < LFOs.capacity()) { |
893 |
LFOv2Unit lfo(this); |
LFOv2Unit lfo(this); |
939 |
Units.clear(); |
Units.clear(); |
940 |
|
|
941 |
Units.add(&suVolOnCC); |
Units.add(&suVolOnCC); |
942 |
|
Units.add(&suCutoffOnCC); |
943 |
|
Units.add(&suResOnCC); |
944 |
|
|
945 |
Units.add(&suVolEG); |
Units.add(&suVolEG); |
946 |
Units.add(&suFilEG); |
Units.add(&suFilEG); |
1004 |
|
|
1005 |
void SfzSignalUnitRack::Reset() { |
void SfzSignalUnitRack::Reset() { |
1006 |
suVolOnCC.RemoveAllCCs(); |
suVolOnCC.RemoveAllCCs(); |
1007 |
|
suCutoffOnCC.RemoveAllCCs(); |
1008 |
|
suResOnCC.RemoveAllCCs(); |
1009 |
suEndpoint.suXFInCC.RemoveAllCCs(); |
suEndpoint.suXFInCC.RemoveAllCCs(); |
1010 |
suEndpoint.suXFOutCC.RemoveAllCCs(); |
suEndpoint.suXFOutCC.RemoveAllCCs(); |
1011 |
suEndpoint.suPanOnCC.RemoveAllCCs(); |
suEndpoint.suPanOnCC.RemoveAllCCs(); |