29 |
|
|
30 |
namespace LinuxSampler { namespace sf2 { |
namespace LinuxSampler { namespace sf2 { |
31 |
|
|
32 |
Voice::Voice() { |
Voice::Voice(): SignalRack(this) { |
33 |
pEngine = NULL; |
pEngine = NULL; |
34 |
pEG1 = &EG1; |
pEG1 = &EG1; |
35 |
pEG2 = &EG2; |
pEG2 = &EG2; |
39 |
|
|
40 |
} |
} |
41 |
|
|
42 |
|
void Voice::AboutToTrigger() { |
43 |
|
|
44 |
|
} |
45 |
|
|
46 |
EngineChannel* Voice::GetSf2EngineChannel() { |
EngineChannel* Voice::GetSf2EngineChannel() { |
47 |
return static_cast<EngineChannel*>(pEngineChannel); |
return static_cast<EngineChannel*>(pEngineChannel); |
48 |
} |
} |
76 |
::sf2::Preset* preset = GetSf2EngineChannel()->pInstrument; |
::sf2::Preset* preset = GetSf2EngineChannel()->pInstrument; |
77 |
for (int i = 0; i < preset->GetRegionCount(); i++) { // TODO: some optimization? |
for (int i = 0; i < preset->GetRegionCount(); i++) { // TODO: some optimization? |
78 |
if (preset->GetRegion(i)->pInstrument == pRegion->GetParentInstrument()) { |
if (preset->GetRegion(i)->pInstrument == pRegion->GetParentInstrument()) { |
79 |
reg = preset->GetRegion(i); // TODO: Can the instrument belongs to more than one preset regions? |
reg = preset->GetRegion(i); // TODO: Can the instrument belong to more than one preset region? |
80 |
break; |
break; |
81 |
} |
} |
82 |
} |
} |
83 |
|
pPresetRegion = reg; |
84 |
|
|
85 |
RegionInfo ri; |
RegionInfo ri; |
86 |
ri.UnityNote = pRegion->GetUnityNote(); |
ri.UnityNote = pRegion->GetUnityNote(); |
87 |
ri.FineTune = pRegion->GetFineTune(reg) + (pRegion->GetCoarseTune(reg) * 100); |
ri.FineTune = pRegion->GetFineTune(reg) + (pRegion->GetCoarseTune(reg) * 100); |
88 |
ri.Pan = pRegion->GetPan(reg); |
ri.Pan = pRegion->GetPan(reg); |
89 |
ri.SampleStartOffset = pRegion->startAddrsOffset + pRegion->startAddrsCoarseOffset; |
ri.SampleStartOffset = pRegion->startAddrsOffset + pRegion->startAddrsCoarseOffset; |
90 |
|
|
|
// sample amplitude |
|
|
ri.EG1PreAttack = 1000; |
|
|
ri.EG1Attack = pRegion->GetEG1Attack(reg); |
|
|
ri.EG1Hold = pRegion->GetEG1Hold(reg); |
|
|
ri.EG1Decay1 = pRegion->GetEG1Decay(reg); |
|
|
ri.EG1Decay2 = pRegion->GetEG1Decay(reg); |
|
|
ri.EG1Sustain = pRegion->GetEG1Sustain(reg); |
|
|
ri.EG1InfiniteSustain = true; |
|
|
ri.EG1Release = pRegion->GetEG1Release(reg); |
|
|
|
|
91 |
// filter cutoff frequency |
// filter cutoff frequency |
92 |
ri.EG2PreAttack = 1000; |
ri.EG2PreAttack = 1000; |
93 |
ri.EG2Attack = pRegion->GetEG2Attack(reg); |
ri.EG2Attack = pRegion->GetEG2Attack(reg); |
213 |
} |
} |
214 |
|
|
215 |
void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { |
void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) { |
216 |
EG1.trigger(uint(RgnInfo.EG1PreAttack), |
EG1.trigger(0, |
217 |
RgnInfo.EG1Attack * egInfo.Attack, |
pRegion->GetEG1Attack(pPresetRegion), |
218 |
RgnInfo.EG1Hold, |
pRegion->GetEG1Hold(pPresetRegion), |
219 |
RgnInfo.EG1Decay1 * egInfo.Decay * velrelease, |
pRegion->GetEG1Decay(pPresetRegion), |
220 |
RgnInfo.EG1Decay2 * egInfo.Decay * velrelease, |
uint(pRegion->GetEG1Sustain(pPresetRegion)), |
221 |
RgnInfo.EG1InfiniteSustain, |
pRegion->GetEG1Release(pPresetRegion), |
|
uint(RgnInfo.EG1Sustain), |
|
|
RgnInfo.EG1Release * egInfo.Release * velrelease, |
|
|
velocityAttenuation, |
|
222 |
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
223 |
} |
} |
224 |
|
|
405 |
}*/ // TODO: ^^^ |
}*/ // TODO: ^^^ |
406 |
bLFO3Enabled = false; |
bLFO3Enabled = false; |
407 |
} |
} |
408 |
|
|
409 |
|
SignalUnitRack* Voice::GetSignalUnitRack() { |
410 |
|
return static_cast<SignalUnitRack*> (&SignalRack); |
411 |
|
} |
412 |
|
|
413 |
float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) { |
float Voice::CalculateCutoffBase(uint8_t MIDIKeyVelocity) { |
414 |
/*float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity); |
/*float cutoff = pRegion->GetVelocityCutoff(MIDIKeyVelocity); |