21 |
***************************************************************************/ |
***************************************************************************/ |
22 |
|
|
23 |
#include "SfzSignalUnitRack.h" |
#include "SfzSignalUnitRack.h" |
24 |
#include "Voice.h" |
#include "Engine.h" |
25 |
#include <SF.h> |
|
26 |
|
#define _200TH_ROOT_OF_10 1.011579454259899 |
27 |
|
|
28 |
namespace LinuxSampler { namespace sfz { |
namespace LinuxSampler { namespace sfz { |
29 |
|
|
30 |
|
double ToRatio(int Centibels) { |
31 |
|
if (Centibels == 0) return 1.0; |
32 |
|
return pow(_200TH_ROOT_OF_10, Centibels); |
33 |
|
} |
34 |
|
|
35 |
SfzSignalUnit::SfzSignalUnit(SfzSignalUnitRack* rack): SignalUnit(rack), pVoice(rack->pVoice) { |
SfzSignalUnit::SfzSignalUnit(SfzSignalUnitRack* rack): SignalUnit(rack), pVoice(rack->pVoice) { |
36 |
|
|
37 |
} |
} |
49 |
return f; |
return f; |
50 |
} |
} |
51 |
|
|
52 |
|
void XFInCCUnit::SetCrossFadeCCs(::sfz::Array<int>& loCCs, ::sfz::Array<int>& hiCCs) { |
53 |
|
RemoveAllCCs(); |
54 |
|
|
55 |
|
for (int cc = 0; cc < 128; cc++) { |
56 |
|
if (loCCs[cc] == 0 && hiCCs[cc] == 0) continue; |
57 |
|
int i = loCCs[cc]; |
58 |
|
int j = hiCCs[cc]; |
59 |
|
if (j == 0) j = 127; |
60 |
|
i += j << 8; // workaround to keep both values in the Influence parameter |
61 |
|
AddCC(cc, i); |
62 |
|
} |
63 |
|
} |
64 |
|
|
65 |
|
void XFInCCUnit::Calculate() { |
66 |
|
float l = 1; |
67 |
|
|
68 |
|
RTList<CC>::Iterator ctrl = pCtrls->first(); |
69 |
|
RTList<CC>::Iterator end = pCtrls->end(); |
70 |
|
for(; ctrl != end; ++ctrl) { |
71 |
|
float c = 1; |
72 |
|
int influence = (*ctrl).Influence; |
73 |
|
int lo = influence & 0xff; |
74 |
|
int hi = influence >> 8; |
75 |
|
if ((*ctrl).Value <= lo) { |
76 |
|
c = 0; |
77 |
|
} else if ((*ctrl).Value >= hi) { |
78 |
|
c = 1; |
79 |
|
} else { |
80 |
|
float xfVelSize = hi - lo; |
81 |
|
float velPos = (*ctrl).Value - lo; |
82 |
|
c = velPos / xfVelSize; |
83 |
|
if (pVoice->pRegion->xf_cccurve == ::sfz::POWER) { |
84 |
|
c = sin(c * M_PI / 2.0); |
85 |
|
} |
86 |
|
} |
87 |
|
|
88 |
|
l *= c; |
89 |
|
} |
90 |
|
|
91 |
|
if (Level != l) { |
92 |
|
Level = l; |
93 |
|
if (pListener != NULL) pListener->ValueChanged(this); |
94 |
|
} |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
void XFOutCCUnit::Calculate() { |
99 |
|
float l = 1; |
100 |
|
|
101 |
|
RTList<CC>::Iterator ctrl = pCtrls->first(); |
102 |
|
RTList<CC>::Iterator end = pCtrls->end(); |
103 |
|
for(; ctrl != end; ++ctrl) { |
104 |
|
float c = 1; |
105 |
|
int influence = (*ctrl).Influence; |
106 |
|
int lo = influence & 0xff; |
107 |
|
int hi = influence >> 8; |
108 |
|
if ((*ctrl).Value >= hi) { |
109 |
|
c = 0; |
110 |
|
} else if ((*ctrl).Value <= lo) { |
111 |
|
c = 1; |
112 |
|
} else { |
113 |
|
float xfVelSize = hi - lo; |
114 |
|
float velPos = (*ctrl).Value - lo; |
115 |
|
c = 1.0f - velPos / xfVelSize; |
116 |
|
if (pVoice->pRegion->xf_cccurve == ::sfz::POWER) { |
117 |
|
c = sin(c * M_PI / 2.0); |
118 |
|
} |
119 |
|
} |
120 |
|
|
121 |
|
l *= c; |
122 |
|
} |
123 |
|
|
124 |
|
if (Level != l) { |
125 |
|
Level = l; |
126 |
|
if (pListener != NULL) pListener->ValueChanged(this); |
127 |
|
} |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
EGv2Unit::EGv2Unit(SfzSignalUnitRack* rack) |
EGv2Unit::EGv2Unit(SfzSignalUnitRack* rack) |
132 |
: EGUnit< ::LinuxSampler::sfz::EG>(rack), |
: EGUnit< ::LinuxSampler::sfz::EG>(rack), suAmpOnCC(rack), suVolOnCC(rack), |
133 |
suAmpOnCC(rack), suVolOnCC(rack), suPitchOnCC(rack), suCutoffOnCC(rack), suResOnCC(rack) |
suPitchOnCC(rack), suCutoffOnCC(rack), suResOnCC(rack), suPanOnCC(rack) |
134 |
{ } |
{ } |
135 |
|
|
136 |
void EGv2Unit::Trigger() { |
void EGv2Unit::Trigger() { |
311 |
|
|
312 |
void AmpLFOUnit::Trigger() { |
void AmpLFOUnit::Trigger() { |
313 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
314 |
pLfoInfo->delay = pRegion->amplfo_delay; |
pLfoInfo->delay = pRegion->amplfo_delay + GetInfluence(pRegion->amplfo_delay_oncc); |
315 |
pLfoInfo->freq = pRegion->amplfo_freq; |
pLfoInfo->freq = pRegion->amplfo_freq; |
316 |
pLfoInfo->fade = pRegion->amplfo_fade; |
pLfoInfo->fade = pRegion->amplfo_fade + GetInfluence(pRegion->amplfo_fade_oncc); |
317 |
pLfoInfo->volume = pRegion->amplfo_depth; |
pLfoInfo->volume = pRegion->amplfo_depth; |
318 |
|
|
319 |
LFOv1Unit::Trigger(); |
LFOv1Unit::Trigger(); |
321 |
|
|
322 |
void PitchLFOUnit::Trigger() { |
void PitchLFOUnit::Trigger() { |
323 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
324 |
pLfoInfo->delay = pRegion->pitchlfo_delay; |
pLfoInfo->delay = pRegion->pitchlfo_delay + GetInfluence(pRegion->pitchlfo_delay_oncc); |
325 |
pLfoInfo->freq = pRegion->pitchlfo_freq; |
pLfoInfo->freq = pRegion->pitchlfo_freq; |
326 |
pLfoInfo->fade = pRegion->pitchlfo_fade; |
pLfoInfo->fade = pRegion->pitchlfo_fade + GetInfluence(pRegion->pitchlfo_fade_oncc); |
327 |
pLfoInfo->pitch = pRegion->pitchlfo_depth; |
pLfoInfo->pitch = pRegion->pitchlfo_depth; |
328 |
|
|
329 |
LFOv1Unit::Trigger(); |
LFOv1Unit::Trigger(); |
331 |
|
|
332 |
void FilLFOUnit::Trigger() { |
void FilLFOUnit::Trigger() { |
333 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
334 |
pLfoInfo->delay = pRegion->fillfo_delay; |
pLfoInfo->delay = pRegion->fillfo_delay + GetInfluence(pRegion->fillfo_delay_oncc); |
335 |
pLfoInfo->freq = pRegion->fillfo_freq; |
pLfoInfo->freq = pRegion->fillfo_freq; |
336 |
pLfoInfo->fade = pRegion->fillfo_fade; |
pLfoInfo->fade = pRegion->fillfo_fade + GetInfluence(pRegion->fillfo_fade_oncc); |
337 |
pLfoInfo->cutoff = pRegion->fillfo_depth; |
pLfoInfo->cutoff = pRegion->fillfo_depth; |
338 |
|
|
339 |
LFOv1Unit::Trigger(); |
LFOv1Unit::Trigger(); |
344 |
} |
} |
345 |
|
|
346 |
void CCUnit::Trigger() { |
void CCUnit::Trigger() { |
347 |
for (int i = 0; i < Ctrls.size(); i++) { |
RTList<CC>::Iterator ctrl = pCtrls->first(); |
348 |
Ctrls[i].Value = pVoice->GetControllerValue(Ctrls[i].Controller); |
RTList<CC>::Iterator end = pCtrls->end(); |
349 |
if (Ctrls[i].pSmoother != NULL) Ctrls[i].pSmoother->setValue(Ctrls[i].Value); |
for(; ctrl != end; ++ctrl) { |
350 |
|
(*ctrl).Value = pVoice->GetControllerValue((*ctrl).Controller); |
351 |
|
if ((*ctrl).pSmoother != NULL) (*ctrl).pSmoother->setValue((*ctrl).Value); |
352 |
} |
} |
353 |
CCSignalUnit::Trigger(); |
CCSignalUnit::Trigger(); |
354 |
} |
} |
355 |
|
|
356 |
void CCUnit::SetCCs(::sfz::Array<int>& cc) { |
void CCUnit::SetCCs(::sfz::Array<int>& cc) { |
357 |
RemoveAllCCs(); |
RemoveAllCCs(); |
358 |
for (int i = 0; i < 128; i++) { |
for (int i = 0; i < 128; i++) { |
359 |
if (cc[i] != 0) AddCC(i, cc[i]); |
if (cc[i] != 0) AddCC(i, cc[i]); |
360 |
} |
} |
361 |
} |
} |
362 |
|
|
363 |
void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) { |
void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) { |
364 |
RemoveAllCCs(); |
RemoveAllCCs(); |
365 |
for (int i = 0; i < cc.size(); i++) { |
for (int i = 0; i < cc.size(); i++) { |
366 |
if (cc[i].Influence != 0) { |
if (cc[i].Influence != 0) { |
367 |
short int curve = cc[i].Curve; |
short int curve = cc[i].Curve; |
368 |
if (curve >= GetCurveCount()) curve = -1; |
if (curve >= GetCurveCount()) curve = -1; |
369 |
AddSmoothCC(cc[i].Controller, cc[i].Influence, curve, cc[i].Smooth); |
AddSmoothCC(cc[i].Controller, cc[i].Influence, curve, cc[i].Smooth); |
370 |
} |
} |
371 |
} |
} |
372 |
} |
} |
373 |
|
|
374 |
void CCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { |
void CCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { |
375 |
AddCC(Controller, Influence, Curve); |
AddCC(Controller, Influence, Curve); |
376 |
} |
} |
377 |
|
|
378 |
int CCUnit::GetCurveCount() { |
int CCUnit::GetCurveCount() { |
379 |
return pVoice->pRegion->GetInstrument()->curves.size(); |
return pVoice->pRegion->GetInstrument()->curves.size(); |
380 |
} |
} |
381 |
|
|
382 |
::sfz::Curve* CCUnit::GetCurve(int idx) { |
::sfz::Curve* CCUnit::GetCurve(int idx) { |
383 |
return &pVoice->pRegion->GetInstrument()->curves[idx]; |
return &pVoice->pRegion->GetInstrument()->curves[idx]; |
384 |
} |
} |
385 |
|
|
386 |
double CCUnit::GetSampleRate() { |
double CCUnit::GetSampleRate() { |
387 |
return pVoice->GetSampleRate() / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
return pVoice->GetSampleRate() / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
388 |
} |
} |
389 |
|
|
390 |
|
|
391 |
|
SmoothCCUnit::~SmoothCCUnit() { |
392 |
|
if (pSmoothers != NULL) delete pSmoothers; |
393 |
|
} |
394 |
|
|
395 |
|
void SmoothCCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { |
396 |
|
if (Smooth > 0) { |
397 |
|
if (pSmoothers->poolIsEmpty()) { |
398 |
|
std::cerr << "Maximum number of smoothers reached" << std::endl; |
399 |
|
return; |
400 |
|
} |
401 |
|
Smoother* smoother = &(*(pSmoothers->allocAppend())); |
402 |
|
smoother->trigger(Smooth / 1000.0f, GetSampleRate()); |
403 |
|
AddCC(Controller, Influence, Curve, smoother); |
404 |
|
} else { |
405 |
|
AddCC(Controller, Influence, Curve); |
406 |
|
} |
407 |
|
} |
408 |
|
|
409 |
void SmoothCCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { |
void SmoothCCUnit::InitSmoothers(Pool<Smoother>* pSmootherPool) { |
410 |
if (Smooth > 0) { |
if (pSmoothers != NULL) delete pSmoothers; |
411 |
Smoothers[Controller].trigger(Smooth / 1000.0f, GetSampleRate()); |
pSmoothers = new RTList<Smoother>(pSmootherPool); |
412 |
AddCC(Controller, Influence, Curve, &Smoothers[Controller]); |
} |
413 |
} else { |
|
414 |
AddCC(Controller, Influence, Curve); |
void SmoothCCUnit::InitCCList(Pool<CC>* pCCPool, Pool<Smoother>* pSmootherPool) { |
415 |
} |
CurveCCUnit::InitCCList(pCCPool, pSmootherPool); |
416 |
} |
InitSmoothers(pSmootherPool); |
417 |
|
} |
418 |
|
|
419 |
|
|
420 |
EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack): EndpointSignalUnit(rack) { |
EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack) |
421 |
|
: EndpointSignalUnit(rack), suXFInCC(rack), suXFOutCC(rack), suPanOnCC(rack), pitchVeltrackRatio(0) |
422 |
|
{ |
423 |
|
|
424 |
} |
} |
425 |
|
|
428 |
} |
} |
429 |
|
|
430 |
void EndpointUnit::Trigger() { |
void EndpointUnit::Trigger() { |
431 |
|
float xfInVelCoeff = 1; |
432 |
|
|
433 |
|
if (pVoice->MIDIVelocity <= pVoice->pRegion->xfin_lovel) { |
434 |
|
xfInVelCoeff = 0; |
435 |
|
} else if (pVoice->MIDIVelocity >= pVoice->pRegion->xfin_hivel) { |
436 |
|
xfInVelCoeff = 1; |
437 |
|
} else { |
438 |
|
float xfVelSize = pVoice->pRegion->xfin_hivel - pVoice->pRegion->xfin_lovel; |
439 |
|
float velPos = pVoice->MIDIVelocity - pVoice->pRegion->xfin_lovel; |
440 |
|
xfInVelCoeff = velPos / xfVelSize; |
441 |
|
if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) { |
442 |
|
xfInVelCoeff = sin(xfInVelCoeff * M_PI / 2.0); |
443 |
|
} |
444 |
|
} |
445 |
|
|
446 |
|
float xfOutVelCoeff = 1; |
447 |
|
|
448 |
|
if (pVoice->MIDIVelocity >= pVoice->pRegion->xfout_hivel) { |
449 |
|
if (pVoice->pRegion->xfout_lovel < 127 /* is set */) xfOutVelCoeff = 0; |
450 |
|
} else if (pVoice->MIDIVelocity <= pVoice->pRegion->xfout_lovel) { |
451 |
|
xfOutVelCoeff = 1; |
452 |
|
} else { |
453 |
|
float xfVelSize = pVoice->pRegion->xfout_hivel - pVoice->pRegion->xfout_lovel; |
454 |
|
float velPos = pVoice->MIDIVelocity - pVoice->pRegion->xfout_lovel; |
455 |
|
xfOutVelCoeff = 1.0f - velPos / xfVelSize; |
456 |
|
if (pVoice->pRegion->xf_velcurve == ::sfz::POWER) { |
457 |
|
xfOutVelCoeff = sin(xfOutVelCoeff * M_PI / 2.0); |
458 |
|
} |
459 |
|
} |
460 |
|
|
461 |
|
float xfInKeyCoeff = 1; |
462 |
|
|
463 |
|
if (pVoice->MIDIKey <= pVoice->pRegion->xfin_lokey) { |
464 |
|
if (pVoice->pRegion->xfin_hikey > 0 /* is set */) xfInKeyCoeff = 0; |
465 |
|
} else if (pVoice->MIDIKey >= pVoice->pRegion->xfin_hikey) { |
466 |
|
xfInKeyCoeff = 1; |
467 |
|
} else { |
468 |
|
float xfKeySize = pVoice->pRegion->xfin_hikey - pVoice->pRegion->xfin_lokey; |
469 |
|
float keyPos = pVoice->MIDIKey - pVoice->pRegion->xfin_lokey; |
470 |
|
xfInKeyCoeff = keyPos / xfKeySize; |
471 |
|
if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) { |
472 |
|
xfInKeyCoeff = sin(xfInKeyCoeff * M_PI / 2.0); |
473 |
|
} |
474 |
|
} |
475 |
|
|
476 |
|
float xfOutKeyCoeff = 1; |
477 |
|
|
478 |
|
if (pVoice->MIDIKey >= pVoice->pRegion->xfout_hikey) { |
479 |
|
if (pVoice->pRegion->xfout_lokey < 127 /* is set */) xfOutKeyCoeff = 0; |
480 |
|
} else if (pVoice->MIDIKey <= pVoice->pRegion->xfout_lokey) { |
481 |
|
xfOutKeyCoeff = 1; |
482 |
|
} else { |
483 |
|
float xfKeySize = pVoice->pRegion->xfout_hikey - pVoice->pRegion->xfout_lokey; |
484 |
|
float keyPos = pVoice->MIDIKey - pVoice->pRegion->xfout_lokey; |
485 |
|
xfOutKeyCoeff = 1.0f - keyPos / xfKeySize; |
486 |
|
if (pVoice->pRegion->xf_keycurve == ::sfz::POWER) { |
487 |
|
xfOutKeyCoeff = sin(xfOutKeyCoeff * M_PI / 2.0); |
488 |
|
} |
489 |
|
} |
490 |
|
|
491 |
|
xfCoeff = xfInVelCoeff * xfOutVelCoeff * xfInKeyCoeff * xfOutKeyCoeff; |
492 |
|
|
493 |
|
suXFInCC.SetCrossFadeCCs(pVoice->pRegion->xfin_locc, pVoice->pRegion->xfin_hicc); |
494 |
|
suXFOutCC.SetCrossFadeCCs(pVoice->pRegion->xfout_locc, pVoice->pRegion->xfout_hicc); |
495 |
|
|
496 |
|
suPanOnCC.SetCCs(pVoice->pRegion->pan_oncc); |
497 |
|
|
498 |
|
pitchVeltrackRatio = RTMath::CentsToFreqRatioUnlimited((pVoice->MIDIVelocity / 127.0f) * pVoice->pRegion->pitch_veltrack); |
499 |
} |
} |
500 |
|
|
501 |
bool EndpointUnit::Active() { |
bool EndpointUnit::Active() { |
525 |
|
|
526 |
if (dB >= -144) { |
if (dB >= -144) { |
527 |
if (amp == 0 && eg->suAmpOnCC.GetCCCount() == 0) amp = 1.0f; |
if (amp == 0 && eg->suAmpOnCC.GetCCCount() == 0) amp = 1.0f; |
528 |
amp *= ::sf2::ToRatio(dB * 10.0); |
amp *= ToRatio(dB * 10.0); |
529 |
} |
} |
530 |
|
|
531 |
vol += amp * eg->GetLevel(); |
vol += amp * eg->GetLevel(); |
534 |
AmpLFOUnit* u = &(GetRack()->suAmpLFO); |
AmpLFOUnit* u = &(GetRack()->suAmpLFO); |
535 |
CCSignalUnit* u2 = &(GetRack()->suAmpLFO.suDepthOnCC); |
CCSignalUnit* u2 = &(GetRack()->suAmpLFO.suDepthOnCC); |
536 |
float f = u2->Active() ? u2->GetLevel() : 0; |
float f = u2->Active() ? u2->GetLevel() : 0; |
537 |
vol *= u->Active() ? ::sf2::ToRatio((u->GetLevel() * (u->pLfoInfo->volume + f) * 10.0)) : 1; |
vol *= u->Active() ? ToRatio((u->GetLevel() * (u->pLfoInfo->volume + f) * 10.0)) : 1; |
538 |
|
|
539 |
vol *= ::sf2::ToRatio(GetRack()->suVolOnCC.GetLevel() * 10.0); |
vol *= ToRatio(GetRack()->suVolOnCC.GetLevel() * 10.0); |
540 |
|
|
541 |
for (int i = 0; i < GetRack()->volLFOs.size(); i++) { |
for (int i = 0; i < GetRack()->volLFOs.size(); i++) { |
542 |
LFOv2Unit* lfo = GetRack()->volLFOs[i]; |
LFOv2Unit* lfo = GetRack()->volLFOs[i]; |
543 |
if (!lfo->Active()) continue; |
if (!lfo->Active()) continue; |
544 |
|
|
545 |
float f = lfo->suVolOnCC.Active() ? lfo->suVolOnCC.GetLevel() : 0; |
float f = lfo->suVolOnCC.Active() ? lfo->suVolOnCC.GetLevel() : 0; |
546 |
vol *= ::sf2::ToRatio(lfo->GetLevel() * (lfo->pLfoInfo->volume + f) * 10.0); |
vol *= ToRatio(lfo->GetLevel() * (lfo->pLfoInfo->volume + f) * 10.0); |
547 |
} |
} |
548 |
|
|
549 |
return vol; |
if (suXFInCC.Active()) vol *= suXFInCC.GetLevel(); |
550 |
|
if (suXFOutCC.Active()) vol *= suXFOutCC.GetLevel(); |
551 |
|
return vol * xfCoeff; |
552 |
} |
} |
553 |
|
|
554 |
float EndpointUnit::GetFilterCutoff() { |
float EndpointUnit::GetFilterCutoff() { |
615 |
p *= RTMath::CentsToFreqRatioUnlimited(lfo->GetLevel() * (lfo->pLfoInfo->pitch + f)); |
p *= RTMath::CentsToFreqRatioUnlimited(lfo->GetLevel() * (lfo->pLfoInfo->pitch + f)); |
616 |
} |
} |
617 |
|
|
618 |
return p; |
return p * pitchVeltrackRatio; |
619 |
} |
} |
620 |
|
|
621 |
float EndpointUnit::GetResonance() { |
float EndpointUnit::GetResonance() { |
641 |
} |
} |
642 |
|
|
643 |
float EndpointUnit::GetPan() { |
float EndpointUnit::GetPan() { |
644 |
float pan = 0; |
float pan = suPanOnCC.Active() ? suPanOnCC.GetLevel() : 0; |
645 |
|
|
646 |
|
for (int i = 0; i < GetRack()->panEGs.size(); i++) { |
647 |
|
EGv2Unit* eg = GetRack()->panEGs[i]; |
648 |
|
if (!eg->Active()) continue; |
649 |
|
|
650 |
|
float f = eg->suPanOnCC.Active() ? eg->suPanOnCC.GetLevel() : 0; |
651 |
|
|
652 |
|
if (eg->pEGInfo->pan_curve >= 0 && eg->pEGInfo->pan_curve < suPanOnCC.GetCurveCount()) { |
653 |
|
uint8_t val = eg->GetLevel() * 127; |
654 |
|
if (val > 127) val = 127; |
655 |
|
pan += eg->pEGInfo->pan * suPanOnCC.GetCurve(eg->pEGInfo->pan_curve)->v[val] + eg->GetLevel() * f; |
656 |
|
} else { |
657 |
|
pan += eg->GetLevel() * (eg->pEGInfo->pan + f); |
658 |
|
} |
659 |
|
} |
660 |
|
|
661 |
for (int i = 0; i < GetRack()->panLFOs.size(); i++) { |
for (int i = 0; i < GetRack()->panLFOs.size(); i++) { |
662 |
LFOv2Unit* lfo = GetRack()->panLFOs[i]; |
LFOv2Unit* lfo = GetRack()->panLFOs[i]; |
675 |
|
|
676 |
SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) |
SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) |
677 |
: SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), |
: SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), |
678 |
EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount), resEGs(maxEgCount), suVolOnCC(this), |
EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), filEGs(maxEgCount), resEGs(maxEgCount), panEGs(maxEgCount), suVolOnCC(this), |
679 |
suAmpLFO(this), suPitchLFO(this), suFilLFO(this), |
suAmpLFO(this), suPitchLFO(this), suFilLFO(this), |
680 |
LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount), |
LFOs(maxLfoCount), volLFOs(maxLfoCount), pitchLFOs(maxLfoCount), |
681 |
filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount) |
filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount) |
682 |
{ |
{ |
683 |
suEndpoint.pVoice = suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; |
suEndpoint.pVoice = suEndpoint.suXFInCC.pVoice = suEndpoint.suXFOutCC.pVoice = suEndpoint.suPanOnCC.pVoice = voice; |
684 |
|
suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; |
685 |
suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = suVolOnCC.pVoice = voice; |
suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = suVolOnCC.pVoice = voice; |
686 |
suPitchLFO.suDepthOnCC.pVoice = suPitchLFO.suFadeEG.pVoice = suPitchLFO.suFreqOnCC.pVoice = voice; |
suPitchLFO.suDepthOnCC.pVoice = suPitchLFO.suFadeEG.pVoice = suPitchLFO.suFreqOnCC.pVoice = voice; |
687 |
suFilLFO.suFadeEG.pVoice = suFilLFO.suDepthOnCC.pVoice = suFilLFO.suFreqOnCC.pVoice = voice; |
suFilLFO.suFadeEG.pVoice = suFilLFO.suDepthOnCC.pVoice = suFilLFO.suFreqOnCC.pVoice = voice; |
695 |
EGs[i]->suPitchOnCC.pVoice = voice; |
EGs[i]->suPitchOnCC.pVoice = voice; |
696 |
EGs[i]->suCutoffOnCC.pVoice = voice; |
EGs[i]->suCutoffOnCC.pVoice = voice; |
697 |
EGs[i]->suResOnCC.pVoice = voice; |
EGs[i]->suResOnCC.pVoice = voice; |
698 |
|
EGs[i]->suPanOnCC.pVoice = voice; |
699 |
} |
} |
700 |
|
|
701 |
for (int i = 0; i < LFOs.capacity(); i++) { |
for (int i = 0; i < LFOs.capacity(); i++) { |
702 |
LFOs[i] = new LFOv2Unit(this); |
LFOs[i] = new LFOv2Unit(this); |
703 |
LFOs[i]->pVoice = voice; |
LFOs[i]->pVoice = voice; |
704 |
|
LFOs[i]->suDepthOnCC.pVoice = voice; |
705 |
|
LFOs[i]->suFreqOnCC.pVoice = voice; |
706 |
LFOs[i]->suFadeEG.pVoice = voice; |
LFOs[i]->suFadeEG.pVoice = voice; |
707 |
LFOs[i]->suVolOnCC.pVoice = voice; |
LFOs[i]->suVolOnCC.pVoice = voice; |
708 |
LFOs[i]->suPitchOnCC.pVoice = voice; |
LFOs[i]->suPitchOnCC.pVoice = voice; |
723 |
} |
} |
724 |
} |
} |
725 |
|
|
726 |
|
void SfzSignalUnitRack::InitRTLists() { |
727 |
|
Pool<CCSignalUnit::CC>* pCCPool = pVoice->pEngine->pCCPool; |
728 |
|
Pool<Smoother>* pSmootherPool = pVoice->pEngine->pSmootherPool; |
729 |
|
|
730 |
|
suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
731 |
|
suEndpoint.suXFInCC.InitCCList(pCCPool, pSmootherPool); |
732 |
|
suEndpoint.suXFOutCC.InitCCList(pCCPool, pSmootherPool); |
733 |
|
suEndpoint.suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
734 |
|
suPitchLFO.suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
735 |
|
suPitchLFO.suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
736 |
|
suFilLFO.suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
737 |
|
suFilLFO.suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
738 |
|
suAmpLFO.suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
739 |
|
suAmpLFO.suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
740 |
|
|
741 |
|
for (int i = 0; i < EGs.capacity(); i++) { |
742 |
|
EGs[i]->suAmpOnCC.InitCCList(pCCPool, pSmootherPool); |
743 |
|
EGs[i]->suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
744 |
|
EGs[i]->suPitchOnCC.InitCCList(pCCPool, pSmootherPool); |
745 |
|
EGs[i]->suCutoffOnCC.InitCCList(pCCPool, pSmootherPool); |
746 |
|
EGs[i]->suResOnCC.InitCCList(pCCPool, pSmootherPool); |
747 |
|
EGs[i]->suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
748 |
|
} |
749 |
|
|
750 |
|
for (int i = 0; i < LFOs.capacity(); i++) { |
751 |
|
LFOs[i]->suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
752 |
|
LFOs[i]->suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
753 |
|
LFOs[i]->suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
754 |
|
LFOs[i]->suPitchOnCC.InitCCList(pCCPool, pSmootherPool); |
755 |
|
LFOs[i]->suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
756 |
|
LFOs[i]->suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
757 |
|
LFOs[i]->suCutoffOnCC.InitCCList(pCCPool, pSmootherPool); |
758 |
|
LFOs[i]->suResOnCC.InitCCList(pCCPool, pSmootherPool); |
759 |
|
} |
760 |
|
} |
761 |
|
|
762 |
void SfzSignalUnitRack::Trigger() { |
void SfzSignalUnitRack::Trigger() { |
763 |
EGs.clear(); |
EGs.clear(); |
764 |
volEGs.clear(); |
volEGs.clear(); |
765 |
pitchEGs.clear(); |
pitchEGs.clear(); |
766 |
filEGs.clear(); |
filEGs.clear(); |
767 |
resEGs.clear(); |
resEGs.clear(); |
768 |
|
panEGs.clear(); |
769 |
|
|
770 |
LFOs.clear(); |
LFOs.clear(); |
771 |
volLFOs.clear(); |
volLFOs.clear(); |
790 |
EGs[EGs.size() - 1]->suPitchOnCC.SetCCs(pRegion->eg[i].pitch_oncc); |
EGs[EGs.size() - 1]->suPitchOnCC.SetCCs(pRegion->eg[i].pitch_oncc); |
791 |
EGs[EGs.size() - 1]->suCutoffOnCC.SetCCs(pRegion->eg[i].cutoff_oncc); |
EGs[EGs.size() - 1]->suCutoffOnCC.SetCCs(pRegion->eg[i].cutoff_oncc); |
792 |
EGs[EGs.size() - 1]->suResOnCC.SetCCs(pRegion->eg[i].resonance_oncc); |
EGs[EGs.size() - 1]->suResOnCC.SetCCs(pRegion->eg[i].resonance_oncc); |
793 |
|
EGs[EGs.size() - 1]->suPanOnCC.SetCCs(pRegion->eg[i].pan_oncc); |
794 |
} else { std::cerr << "Maximum number of EGs reached!" << std::endl; break; } |
} else { std::cerr << "Maximum number of EGs reached!" << std::endl; break; } |
795 |
|
|
796 |
if ( pRegion->eg[i].amplitude > 0 || !pRegion->eg[i].amplitude_oncc.empty() || |
if ( pRegion->eg[i].amplitude > 0 || !pRegion->eg[i].amplitude_oncc.empty() || |
814 |
if(pitchEGs.size() < pitchEGs.capacity()) pitchEGs.add(EGs[EGs.size() - 1]); |
if(pitchEGs.size() < pitchEGs.capacity()) pitchEGs.add(EGs[EGs.size() - 1]); |
815 |
else std::cerr << "Maximum number of EGs reached!" << std::endl; |
else std::cerr << "Maximum number of EGs reached!" << std::endl; |
816 |
} |
} |
817 |
|
|
818 |
|
if (pRegion->eg[i].pan != 0 || !pRegion->eg[i].pan_oncc.empty()) { |
819 |
|
if(panEGs.size() < panEGs.capacity()) panEGs.add(EGs[EGs.size() - 1]); |
820 |
|
else std::cerr << "Maximum number of EGs reached!" << std::endl; |
821 |
|
} |
822 |
} |
} |
823 |
|
|
824 |
if (pRegion->ampeg_sustain == -1) { |
if (pRegion->ampeg_sustain == -1) { |
907 |
Units.add(&(EGs[i]->suPitchOnCC)); |
Units.add(&(EGs[i]->suPitchOnCC)); |
908 |
Units.add(&(EGs[i]->suCutoffOnCC)); |
Units.add(&(EGs[i]->suCutoffOnCC)); |
909 |
Units.add(&(EGs[i]->suResOnCC)); |
Units.add(&(EGs[i]->suResOnCC)); |
910 |
|
Units.add(&(EGs[i]->suPanOnCC)); |
911 |
} |
} |
912 |
|
|
913 |
for (int i = 0; i < LFOs.size(); i++) { |
for (int i = 0; i < LFOs.size(); i++) { |
922 |
} |
} |
923 |
|
|
924 |
Units.add(&suEndpoint); |
Units.add(&suEndpoint); |
925 |
|
Units.add(&suEndpoint.suXFInCC); |
926 |
|
Units.add(&suEndpoint.suXFOutCC); |
927 |
|
Units.add(&suEndpoint.suPanOnCC); |
928 |
|
|
929 |
SignalUnitRack::Trigger(); |
SignalUnitRack::Trigger(); |
930 |
} |
} |
941 |
} |
} |
942 |
} |
} |
943 |
|
|
944 |
|
void SfzSignalUnitRack::Reset() { |
945 |
|
suVolOnCC.RemoveAllCCs(); |
946 |
|
suEndpoint.suXFInCC.RemoveAllCCs(); |
947 |
|
suEndpoint.suXFOutCC.RemoveAllCCs(); |
948 |
|
suEndpoint.suPanOnCC.RemoveAllCCs(); |
949 |
|
suPitchLFO.suDepthOnCC.RemoveAllCCs(); |
950 |
|
suPitchLFO.suFreqOnCC.RemoveAllCCs(); |
951 |
|
suFilLFO.suDepthOnCC.RemoveAllCCs(); |
952 |
|
suFilLFO.suFreqOnCC.RemoveAllCCs(); |
953 |
|
suAmpLFO.suDepthOnCC.RemoveAllCCs(); |
954 |
|
suAmpLFO.suFreqOnCC.RemoveAllCCs(); |
955 |
|
|
956 |
|
for (int i = 0; i < EGs.capacity(); i++) { |
957 |
|
EGs[i]->suAmpOnCC.RemoveAllCCs(); |
958 |
|
EGs[i]->suVolOnCC.RemoveAllCCs(); |
959 |
|
EGs[i]->suPitchOnCC.RemoveAllCCs(); |
960 |
|
EGs[i]->suCutoffOnCC.RemoveAllCCs(); |
961 |
|
EGs[i]->suResOnCC.RemoveAllCCs(); |
962 |
|
EGs[i]->suPanOnCC.RemoveAllCCs(); |
963 |
|
} |
964 |
|
|
965 |
|
for (int i = 0; i < LFOs.capacity(); i++) { |
966 |
|
LFOs[i]->suDepthOnCC.RemoveAllCCs(); |
967 |
|
LFOs[i]->suFreqOnCC.RemoveAllCCs(); |
968 |
|
LFOs[i]->suVolOnCC.RemoveAllCCs(); |
969 |
|
LFOs[i]->suPitchOnCC.RemoveAllCCs(); |
970 |
|
LFOs[i]->suFreqOnCC.RemoveAllCCs(); |
971 |
|
LFOs[i]->suPanOnCC.RemoveAllCCs(); |
972 |
|
LFOs[i]->suCutoffOnCC.RemoveAllCCs(); |
973 |
|
LFOs[i]->suResOnCC.RemoveAllCCs(); |
974 |
|
} |
975 |
|
} |
976 |
|
|
977 |
}} // namespace LinuxSampler::sfz |
}} // namespace LinuxSampler::sfz |