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 |
} |
} |
65 |
void XFInCCUnit::Calculate() { |
void XFInCCUnit::Calculate() { |
66 |
float l = 1; |
float l = 1; |
67 |
|
|
68 |
for (int i = 0; i < Ctrls.size(); i++) { |
RTList<CC>::Iterator ctrl = pCtrls->first(); |
69 |
|
RTList<CC>::Iterator end = pCtrls->end(); |
70 |
|
for(; ctrl != end; ++ctrl) { |
71 |
float c = 1; |
float c = 1; |
72 |
int influence = Ctrls[i].Influence; |
int influence = (*ctrl).Influence; |
73 |
int lo = influence & 0xff; |
int lo = influence & 0xff; |
74 |
int hi = influence >> 8; |
int hi = influence >> 8; |
75 |
if (Ctrls[i].Value <= lo) { |
if ((*ctrl).Value <= lo) { |
76 |
c = 0; |
c = 0; |
77 |
} else if (Ctrls[i].Value >= hi) { |
} else if ((*ctrl).Value >= hi) { |
78 |
c = 1; |
c = 1; |
79 |
} else { |
} else { |
80 |
float xfVelSize = hi - lo; |
float xfVelSize = hi - lo; |
81 |
float velPos = Ctrls[i].Value - lo; |
float velPos = (*ctrl).Value - lo; |
82 |
c = velPos / xfVelSize; |
c = velPos / xfVelSize; |
83 |
if (pVoice->pRegion->xf_cccurve == ::sfz::POWER) { |
if (pVoice->pRegion->xf_cccurve == ::sfz::POWER) { |
84 |
c = sin(c * M_PI / 2.0); |
c = sin(c * M_PI / 2.0); |
98 |
void XFOutCCUnit::Calculate() { |
void XFOutCCUnit::Calculate() { |
99 |
float l = 1; |
float l = 1; |
100 |
|
|
101 |
for (int i = 0; i < Ctrls.size(); i++) { |
RTList<CC>::Iterator ctrl = pCtrls->first(); |
102 |
|
RTList<CC>::Iterator end = pCtrls->end(); |
103 |
|
for(; ctrl != end; ++ctrl) { |
104 |
float c = 1; |
float c = 1; |
105 |
int influence = Ctrls[i].Influence; |
int influence = (*ctrl).Influence; |
106 |
int lo = influence & 0xff; |
int lo = influence & 0xff; |
107 |
int hi = influence >> 8; |
int hi = influence >> 8; |
108 |
if (Ctrls[i].Value >= hi) { |
if ((*ctrl).Value >= hi) { |
109 |
c = 0; |
c = 0; |
110 |
} else if (Ctrls[i].Value <= lo) { |
} else if ((*ctrl).Value <= lo) { |
111 |
c = 1; |
c = 1; |
112 |
} else { |
} else { |
113 |
float xfVelSize = hi - lo; |
float xfVelSize = hi - lo; |
114 |
float velPos = Ctrls[i].Value - lo; |
float velPos = (*ctrl).Value - lo; |
115 |
c = 1.0f - velPos / xfVelSize; |
c = 1.0f - velPos / xfVelSize; |
116 |
if (pVoice->pRegion->xf_cccurve == ::sfz::POWER) { |
if (pVoice->pRegion->xf_cccurve == ::sfz::POWER) { |
117 |
c = sin(c * M_PI / 2.0); |
c = sin(c * M_PI / 2.0); |
148 |
|
|
149 |
void PitchEGUnit::Trigger() { |
void PitchEGUnit::Trigger() { |
150 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
151 |
depth = pRegion->pitcheg_depth; |
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 |
uiDelayTrigger = (pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease) * GetSampleRate(); |
float delay = pRegion->pitcheg_delay + pRegion->pitcheg_vel2delay * velrelease; |
158 |
|
delay += GetInfluence(pRegion->pitcheg_delay_oncc); |
159 |
|
uiDelayTrigger = std::max(0.0f, delay) * GetSampleRate(); |
160 |
|
|
161 |
|
float start = (pRegion->pitcheg_start + GetInfluence(pRegion->pitcheg_start_oncc)) * 10; |
162 |
|
|
163 |
|
float attack = pRegion->pitcheg_attack + pRegion->pitcheg_vel2attack * velrelease; |
164 |
|
attack = std::max(0.0f, attack + GetInfluence(pRegion->pitcheg_attack_oncc)); |
165 |
|
|
166 |
|
float hold = pRegion->pitcheg_hold + pRegion->pitcheg_vel2hold * velrelease; |
167 |
|
hold = std::max(0.0f, hold + GetInfluence(pRegion->pitcheg_hold_oncc)); |
168 |
|
|
169 |
|
float decay = pRegion->pitcheg_decay + pRegion->pitcheg_vel2decay * velrelease; |
170 |
|
decay = std::max(0.0f, decay + GetInfluence(pRegion->pitcheg_decay_oncc)); |
171 |
|
|
172 |
|
float sustain = pRegion->pitcheg_sustain + pRegion->pitcheg_vel2sustain * velrelease; |
173 |
|
sustain = 10 * (sustain + GetInfluence(pRegion->pitcheg_sustain_oncc)); |
174 |
|
|
175 |
EG.trigger(uint(pRegion->pitcheg_start * 10), |
float release = pRegion->pitcheg_release + pRegion->pitcheg_vel2release * velrelease; |
176 |
std::max(0.0, pRegion->pitcheg_attack + pRegion->pitcheg_vel2attack * velrelease), |
release = std::max(0.0f, release + GetInfluence(pRegion->pitcheg_release_oncc)); |
177 |
std::max(0.0, pRegion->pitcheg_hold + pRegion->pitcheg_vel2hold * velrelease), |
|
178 |
std::max(0.0, pRegion->pitcheg_decay + pRegion->pitcheg_vel2decay * velrelease), |
EG.trigger ( |
179 |
uint(std::min(std::max(0.0, 10 * (pRegion->pitcheg_sustain + pRegion->pitcheg_vel2sustain * velrelease)), 1000.0)), |
uint(std::min(std::max(0.0f, start), 1000.0f)), attack, hold, decay, |
180 |
std::max(0.0, pRegion->pitcheg_release + pRegion->pitcheg_vel2release * velrelease), |
uint(std::min(std::max(0.0f, sustain), 1000.0f)), release, GetSampleRate() |
181 |
GetSampleRate()); |
); |
182 |
} |
} |
183 |
|
|
184 |
|
|
185 |
void FilEGUnit::Trigger() { |
void FilEGUnit::Trigger() { |
186 |
::sfz::Region* const pRegion = pVoice->pRegion; |
::sfz::Region* const pRegion = pVoice->pRegion; |
187 |
depth = pRegion->fileg_depth; |
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 |
uiDelayTrigger = (pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease) * GetSampleRate(); |
float delay = pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease; |
194 |
|
delay += GetInfluence(pRegion->fileg_delay_oncc); |
195 |
|
uiDelayTrigger = std::max(0.0f, delay) * GetSampleRate(); |
196 |
|
|
197 |
|
float start = (pRegion->fileg_start + GetInfluence(pRegion->fileg_start_oncc)) * 10; |
198 |
|
|
199 |
|
float attack = pRegion->fileg_attack + pRegion->fileg_vel2attack * velrelease; |
200 |
|
attack = std::max(0.0f, attack + GetInfluence(pRegion->fileg_attack_oncc)); |
201 |
|
|
202 |
|
float hold = pRegion->fileg_hold + pRegion->fileg_vel2hold * velrelease; |
203 |
|
hold = std::max(0.0f, hold + GetInfluence(pRegion->fileg_hold_oncc)); |
204 |
|
|
205 |
EG.trigger(uint(pRegion->fileg_start * 10), |
float decay = pRegion->fileg_decay + pRegion->fileg_vel2decay * velrelease; |
206 |
std::max(0.0, pRegion->fileg_attack + pRegion->fileg_vel2attack * velrelease), |
decay = std::max(0.0f, decay + GetInfluence(pRegion->fileg_decay_oncc)); |
207 |
std::max(0.0, pRegion->fileg_hold + pRegion->fileg_vel2hold * velrelease), |
|
208 |
std::max(0.0, pRegion->fileg_decay + pRegion->fileg_vel2decay * velrelease), |
float sustain = pRegion->fileg_sustain + pRegion->fileg_vel2sustain * velrelease; |
209 |
uint(std::min(std::max(0.0, 10 * (pRegion->fileg_sustain + pRegion->fileg_vel2sustain * velrelease)), 1000.0)), |
sustain = 10 * (sustain + GetInfluence(pRegion->fileg_sustain_oncc)); |
210 |
std::max(0.0, pRegion->fileg_release + pRegion->fileg_vel2release * velrelease), |
|
211 |
GetSampleRate()); |
float release = pRegion->fileg_release + pRegion->fileg_vel2release * velrelease; |
212 |
|
release = std::max(0.0f, release + GetInfluence(pRegion->fileg_release_oncc)); |
213 |
|
|
214 |
|
EG.trigger ( |
215 |
|
uint(std::min(std::max(0.0f, start), 1000.0f)), attack, hold, decay, |
216 |
|
uint(std::min(std::max(0.0f, sustain), 1000.0f)), release, GetSampleRate() |
217 |
|
); |
218 |
} |
} |
219 |
|
|
220 |
|
|
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; |
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; |
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; |
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; |
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; |
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; |
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 |
|
|
395 |
} |
} |
396 |
|
|
397 |
void CCUnit::Trigger() { |
void CCUnit::Trigger() { |
398 |
for (int i = 0; i < Ctrls.size(); i++) { |
RTList<CC>::Iterator ctrl = pCtrls->first(); |
399 |
Ctrls[i].Value = pVoice->GetControllerValue(Ctrls[i].Controller); |
RTList<CC>::Iterator end = pCtrls->end(); |
400 |
if (Ctrls[i].pSmoother != NULL) Ctrls[i].pSmoother->setValue(Ctrls[i].Value); |
for(; ctrl != end; ++ctrl) { |
401 |
|
(*ctrl).Value = pVoice->GetControllerValue((*ctrl).Controller); |
402 |
|
if ((*ctrl).pSmoother != NULL) (*ctrl).pSmoother->setValue((*ctrl).Value); |
403 |
} |
} |
404 |
CCSignalUnit::Trigger(); |
CCSignalUnit::Trigger(); |
405 |
} |
} |
406 |
|
|
407 |
void CCUnit::SetCCs(::sfz::Array<int>& cc) { |
void CCUnit::SetCCs(::sfz::Array<int>& cc) { |
408 |
RemoveAllCCs(); |
RemoveAllCCs(); |
409 |
for (int i = 0; i < 128; i++) { |
for (int i = 0; i < 128; i++) { |
410 |
if (cc[i] != 0) AddCC(i, cc[i]); |
if (cc[i] != 0) AddCC(i, cc[i]); |
411 |
} |
} |
412 |
} |
} |
413 |
|
|
414 |
void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) { |
void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) { |
415 |
RemoveAllCCs(); |
RemoveAllCCs(); |
416 |
for (int i = 0; i < cc.size(); i++) { |
for (int i = 0; i < cc.size(); i++) { |
417 |
if (cc[i].Influence != 0) { |
if (cc[i].Influence != 0) { |
418 |
short int curve = cc[i].Curve; |
short int curve = cc[i].Curve; |
419 |
if (curve >= GetCurveCount()) curve = -1; |
if (curve >= GetCurveCount()) curve = -1; |
420 |
AddSmoothCC(cc[i].Controller, cc[i].Influence, curve, cc[i].Smooth); |
AddSmoothCC(cc[i].Controller, cc[i].Influence, curve, cc[i].Smooth); |
421 |
} |
} |
422 |
} |
} |
423 |
} |
} |
424 |
|
|
425 |
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) { |
426 |
AddCC(Controller, Influence, Curve); |
AddCC(Controller, Influence, Curve); |
427 |
} |
} |
428 |
|
|
429 |
int CCUnit::GetCurveCount() { |
int CCUnit::GetCurveCount() { |
430 |
return pVoice->pRegion->GetInstrument()->curves.size(); |
return pVoice->pRegion->GetInstrument()->curves.size(); |
431 |
} |
} |
432 |
|
|
433 |
::sfz::Curve* CCUnit::GetCurve(int idx) { |
::sfz::Curve* CCUnit::GetCurve(int idx) { |
434 |
return &pVoice->pRegion->GetInstrument()->curves[idx]; |
return &pVoice->pRegion->GetInstrument()->curves[idx]; |
435 |
} |
} |
436 |
|
|
437 |
double CCUnit::GetSampleRate() { |
double CCUnit::GetSampleRate() { |
438 |
return pVoice->GetSampleRate() / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
return pVoice->GetSampleRate() / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
439 |
} |
} |
440 |
|
|
441 |
|
|
442 |
|
SmoothCCUnit::~SmoothCCUnit() { |
443 |
|
if (pSmoothers != NULL) delete pSmoothers; |
444 |
|
} |
445 |
|
|
446 |
|
void SmoothCCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { |
447 |
|
if (Smooth > 0) { |
448 |
|
if (pSmoothers->poolIsEmpty()) { |
449 |
|
std::cerr << "Maximum number of smoothers reached" << std::endl; |
450 |
|
return; |
451 |
|
} |
452 |
|
Smoother* smoother = &(*(pSmoothers->allocAppend())); |
453 |
|
smoother->trigger(Smooth / 1000.0f, GetSampleRate()); |
454 |
|
AddCC(Controller, Influence, Curve, smoother); |
455 |
|
} else { |
456 |
|
AddCC(Controller, Influence, Curve); |
457 |
|
} |
458 |
|
} |
459 |
|
|
460 |
void SmoothCCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { |
void SmoothCCUnit::InitSmoothers(Pool<Smoother>* pSmootherPool) { |
461 |
if (Smooth > 0) { |
if (pSmoothers != NULL) delete pSmoothers; |
462 |
if (Smoothers.size() >= Smoothers.capacity()) { |
pSmoothers = new RTList<Smoother>(pSmootherPool); |
463 |
std::cerr << "Maximum number of smoothers reached" << std::endl; |
} |
464 |
return; |
|
465 |
} |
void SmoothCCUnit::InitCCList(Pool<CC>* pCCPool, Pool<Smoother>* pSmootherPool) { |
466 |
|
CurveCCUnit::InitCCList(pCCPool, pSmootherPool); |
467 |
Smoothers.increment().trigger(Smooth / 1000.0f, GetSampleRate()); |
InitSmoothers(pSmootherPool); |
468 |
AddCC(Controller, Influence, Curve, &Smoothers[Smoothers.size() - 1]); |
} |
|
} else { |
|
|
AddCC(Controller, Influence, Curve); |
|
|
} |
|
|
} |
|
469 |
|
|
470 |
|
|
471 |
EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack) |
EndpointUnit::EndpointUnit(SfzSignalUnitRack* rack) |
576 |
|
|
577 |
if (dB >= -144) { |
if (dB >= -144) { |
578 |
if (amp == 0 && eg->suAmpOnCC.GetCCCount() == 0) amp = 1.0f; |
if (amp == 0 && eg->suAmpOnCC.GetCCCount() == 0) amp = 1.0f; |
579 |
amp *= ::sf2::ToRatio(dB * 10.0); |
amp *= ToRatio(dB * 10.0); |
580 |
} |
} |
581 |
|
|
582 |
vol += amp * eg->GetLevel(); |
vol += amp * eg->GetLevel(); |
585 |
AmpLFOUnit* u = &(GetRack()->suAmpLFO); |
AmpLFOUnit* u = &(GetRack()->suAmpLFO); |
586 |
CCSignalUnit* u2 = &(GetRack()->suAmpLFO.suDepthOnCC); |
CCSignalUnit* u2 = &(GetRack()->suAmpLFO.suDepthOnCC); |
587 |
float f = u2->Active() ? u2->GetLevel() : 0; |
float f = u2->Active() ? u2->GetLevel() : 0; |
588 |
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; |
589 |
|
|
590 |
vol *= ::sf2::ToRatio(GetRack()->suVolOnCC.GetLevel() * 10.0); |
vol *= ToRatio(GetRack()->suVolOnCC.GetLevel() * 10.0); |
591 |
|
|
592 |
for (int i = 0; i < GetRack()->volLFOs.size(); i++) { |
for (int i = 0; i < GetRack()->volLFOs.size(); i++) { |
593 |
LFOv2Unit* lfo = GetRack()->volLFOs[i]; |
LFOv2Unit* lfo = GetRack()->volLFOs[i]; |
594 |
if (!lfo->Active()) continue; |
if (!lfo->Active()) continue; |
595 |
|
|
596 |
float f = lfo->suVolOnCC.Active() ? lfo->suVolOnCC.GetLevel() : 0; |
float f = lfo->suVolOnCC.Active() ? lfo->suVolOnCC.GetLevel() : 0; |
597 |
vol *= ::sf2::ToRatio(lfo->GetLevel() * (lfo->pLfoInfo->volume + f) * 10.0); |
vol *= ToRatio(lfo->GetLevel() * (lfo->pLfoInfo->volume + f) * 10.0); |
598 |
} |
} |
599 |
|
|
600 |
if (suXFInCC.Active()) vol *= suXFInCC.GetLevel(); |
if (suXFInCC.Active()) vol *= suXFInCC.GetLevel(); |
752 |
for (int i = 0; i < LFOs.capacity(); i++) { |
for (int i = 0; i < LFOs.capacity(); i++) { |
753 |
LFOs[i] = new LFOv2Unit(this); |
LFOs[i] = new LFOv2Unit(this); |
754 |
LFOs[i]->pVoice = voice; |
LFOs[i]->pVoice = voice; |
755 |
|
LFOs[i]->suDepthOnCC.pVoice = voice; |
756 |
|
LFOs[i]->suFreqOnCC.pVoice = voice; |
757 |
LFOs[i]->suFadeEG.pVoice = voice; |
LFOs[i]->suFadeEG.pVoice = voice; |
758 |
LFOs[i]->suVolOnCC.pVoice = voice; |
LFOs[i]->suVolOnCC.pVoice = voice; |
759 |
LFOs[i]->suPitchOnCC.pVoice = voice; |
LFOs[i]->suPitchOnCC.pVoice = voice; |
774 |
} |
} |
775 |
} |
} |
776 |
|
|
777 |
|
void SfzSignalUnitRack::InitRTLists() { |
778 |
|
Pool<CCSignalUnit::CC>* pCCPool = pVoice->pEngine->pCCPool; |
779 |
|
Pool<Smoother>* pSmootherPool = pVoice->pEngine->pSmootherPool; |
780 |
|
|
781 |
|
suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
782 |
|
suEndpoint.suXFInCC.InitCCList(pCCPool, pSmootherPool); |
783 |
|
suEndpoint.suXFOutCC.InitCCList(pCCPool, pSmootherPool); |
784 |
|
suEndpoint.suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
785 |
|
suPitchLFO.suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
786 |
|
suPitchLFO.suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
787 |
|
suFilLFO.suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
788 |
|
suFilLFO.suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
789 |
|
suAmpLFO.suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
790 |
|
suAmpLFO.suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
791 |
|
|
792 |
|
for (int i = 0; i < EGs.capacity(); i++) { |
793 |
|
EGs[i]->suAmpOnCC.InitCCList(pCCPool, pSmootherPool); |
794 |
|
EGs[i]->suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
795 |
|
EGs[i]->suPitchOnCC.InitCCList(pCCPool, pSmootherPool); |
796 |
|
EGs[i]->suCutoffOnCC.InitCCList(pCCPool, pSmootherPool); |
797 |
|
EGs[i]->suResOnCC.InitCCList(pCCPool, pSmootherPool); |
798 |
|
EGs[i]->suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
799 |
|
} |
800 |
|
|
801 |
|
for (int i = 0; i < LFOs.capacity(); i++) { |
802 |
|
LFOs[i]->suDepthOnCC.InitCCList(pCCPool, pSmootherPool); |
803 |
|
LFOs[i]->suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
804 |
|
LFOs[i]->suVolOnCC.InitCCList(pCCPool, pSmootherPool); |
805 |
|
LFOs[i]->suPitchOnCC.InitCCList(pCCPool, pSmootherPool); |
806 |
|
LFOs[i]->suFreqOnCC.InitCCList(pCCPool, pSmootherPool); |
807 |
|
LFOs[i]->suPanOnCC.InitCCList(pCCPool, pSmootherPool); |
808 |
|
LFOs[i]->suCutoffOnCC.InitCCList(pCCPool, pSmootherPool); |
809 |
|
LFOs[i]->suResOnCC.InitCCList(pCCPool, pSmootherPool); |
810 |
|
} |
811 |
|
} |
812 |
|
|
813 |
void SfzSignalUnitRack::Trigger() { |
void SfzSignalUnitRack::Trigger() { |
814 |
EGs.clear(); |
EGs.clear(); |
815 |
volEGs.clear(); |
volEGs.clear(); |
879 |
|
|
880 |
// LFO |
// LFO |
881 |
for (int i = 0; i < pRegion->lfos.size(); i++) { |
for (int i = 0; i < pRegion->lfos.size(); i++) { |
882 |
if (pRegion->lfos[i].freq == -1) continue; // Not initialized |
if (pRegion->lfos[i].freq <= 0) { |
883 |
|
if (pRegion->lfos[i].freq_oncc.empty()) continue; // Not initialized |
884 |
|
else pRegion->lfos[i].freq = 0; |
885 |
|
} |
886 |
|
|
887 |
if(LFOs.size() < LFOs.capacity()) { |
if(LFOs.size() < LFOs.capacity()) { |
888 |
LFOv2Unit lfo(this); |
LFOv2Unit lfo(this); |
995 |
} |
} |
996 |
} |
} |
997 |
|
|
998 |
|
void SfzSignalUnitRack::Reset() { |
999 |
|
suVolOnCC.RemoveAllCCs(); |
1000 |
|
suEndpoint.suXFInCC.RemoveAllCCs(); |
1001 |
|
suEndpoint.suXFOutCC.RemoveAllCCs(); |
1002 |
|
suEndpoint.suPanOnCC.RemoveAllCCs(); |
1003 |
|
suPitchLFO.suDepthOnCC.RemoveAllCCs(); |
1004 |
|
suPitchLFO.suFreqOnCC.RemoveAllCCs(); |
1005 |
|
suFilLFO.suDepthOnCC.RemoveAllCCs(); |
1006 |
|
suFilLFO.suFreqOnCC.RemoveAllCCs(); |
1007 |
|
suAmpLFO.suDepthOnCC.RemoveAllCCs(); |
1008 |
|
suAmpLFO.suFreqOnCC.RemoveAllCCs(); |
1009 |
|
|
1010 |
|
for (int i = 0; i < EGs.capacity(); i++) { |
1011 |
|
EGs[i]->suAmpOnCC.RemoveAllCCs(); |
1012 |
|
EGs[i]->suVolOnCC.RemoveAllCCs(); |
1013 |
|
EGs[i]->suPitchOnCC.RemoveAllCCs(); |
1014 |
|
EGs[i]->suCutoffOnCC.RemoveAllCCs(); |
1015 |
|
EGs[i]->suResOnCC.RemoveAllCCs(); |
1016 |
|
EGs[i]->suPanOnCC.RemoveAllCCs(); |
1017 |
|
} |
1018 |
|
|
1019 |
|
for (int i = 0; i < LFOs.capacity(); i++) { |
1020 |
|
LFOs[i]->suDepthOnCC.RemoveAllCCs(); |
1021 |
|
LFOs[i]->suFreqOnCC.RemoveAllCCs(); |
1022 |
|
LFOs[i]->suVolOnCC.RemoveAllCCs(); |
1023 |
|
LFOs[i]->suPitchOnCC.RemoveAllCCs(); |
1024 |
|
LFOs[i]->suFreqOnCC.RemoveAllCCs(); |
1025 |
|
LFOs[i]->suPanOnCC.RemoveAllCCs(); |
1026 |
|
LFOs[i]->suCutoffOnCC.RemoveAllCCs(); |
1027 |
|
LFOs[i]->suResOnCC.RemoveAllCCs(); |
1028 |
|
} |
1029 |
|
} |
1030 |
|
|
1031 |
}} // namespace LinuxSampler::sfz |
}} // namespace LinuxSampler::sfz |