4 |
* * |
* * |
5 |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009-2011 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * |
8 |
|
* Copyright (C) 2013-2016 Christian Schoenebeck and Andreas Persson * |
9 |
* * |
* * |
10 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
11 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
27 |
|
|
28 |
namespace LinuxSampler { |
namespace LinuxSampler { |
29 |
|
|
30 |
AbstractVoice::AbstractVoice() { |
AbstractVoice::AbstractVoice(SignalUnitRack* pRack): pSignalUnitRack(pRack) { |
31 |
pEngineChannel = NULL; |
pEngineChannel = NULL; |
32 |
pLFO1 = new LFOUnsigned(1.0f); // amplitude LFO (0..1 range) |
pLFO1 = new LFOUnsigned(1.0f); // amplitude LFO (0..1 range) |
33 |
pLFO2 = new LFOUnsigned(1.0f); // filter LFO (0..1 range) |
pLFO2 = new LFOUnsigned(1.0f); // filter LFO (0..1 range) |
44 |
|
|
45 |
finalSynthesisParameters.filterLeft.Reset(); |
finalSynthesisParameters.filterLeft.Reset(); |
46 |
finalSynthesisParameters.filterRight.Reset(); |
finalSynthesisParameters.filterRight.Reset(); |
47 |
|
|
48 |
|
pEq = NULL; |
49 |
|
bEqSupport = false; |
50 |
} |
} |
51 |
|
|
52 |
AbstractVoice::~AbstractVoice() { |
AbstractVoice::~AbstractVoice() { |
53 |
if (pLFO1) delete pLFO1; |
if (pLFO1) delete pLFO1; |
54 |
if (pLFO2) delete pLFO2; |
if (pLFO2) delete pLFO2; |
55 |
if (pLFO3) delete pLFO3; |
if (pLFO3) delete pLFO3; |
56 |
|
|
57 |
|
if(pEq != NULL) delete pEq; |
58 |
|
} |
59 |
|
|
60 |
|
void AbstractVoice::CreateEq() { |
61 |
|
if(!bEqSupport) return; |
62 |
|
if(pEq != NULL) delete pEq; |
63 |
|
pEq = new EqSupport; |
64 |
|
pEq->InitEffect(GetEngine()->pAudioOutputDevice); |
65 |
} |
} |
66 |
|
|
67 |
/** |
/** |
111 |
#endif // CONFIG_DEVMODE |
#endif // CONFIG_DEVMODE |
112 |
|
|
113 |
Type = VoiceType; |
Type = VoiceType; |
114 |
MIDIKey = itNoteOnEvent->Param.Note.Key; |
pNote = pEngineChannel->pEngine->NoteByID( itNoteOnEvent->Param.Note.ID ); |
115 |
PlaybackState = playback_state_init; // mark voice as triggered, but no audio rendered yet |
PlaybackState = playback_state_init; // mark voice as triggered, but no audio rendered yet |
116 |
Delay = itNoteOnEvent->FragmentPos(); |
Delay = itNoteOnEvent->FragmentPos(); |
117 |
itTriggerEvent = itNoteOnEvent; |
itTriggerEvent = itNoteOnEvent; |
118 |
itKillEvent = Pool<Event>::Iterator(); |
itKillEvent = Pool<Event>::Iterator(); |
119 |
MidiKeyBase* pKeyInfo = GetMidiKeyInfo(MIDIKey); |
MidiKeyBase* pKeyInfo = GetMidiKeyInfo(MIDIKey()); |
120 |
|
|
121 |
pGroupEvents = iKeyGroup ? pEngineChannel->ActiveKeyGroups[iKeyGroup] : 0; |
pGroupEvents = iKeyGroup ? pEngineChannel->ActiveKeyGroups[iKeyGroup] : 0; |
122 |
|
|
124 |
RgnInfo = GetRegionInfo(); |
RgnInfo = GetRegionInfo(); |
125 |
InstrInfo = GetInstrumentInfo(); |
InstrInfo = GetInstrumentInfo(); |
126 |
|
|
127 |
|
MIDIPan = CalculatePan(pEngineChannel->iLastPanRequest); |
128 |
|
|
129 |
AboutToTrigger(); |
AboutToTrigger(); |
130 |
|
|
131 |
// calculate volume |
// calculate volume |
141 |
// get starting crossfade volume level |
// get starting crossfade volume level |
142 |
float crossfadeVolume = CalculateCrossfadeVolume(itNoteOnEvent->Param.Note.Velocity); |
float crossfadeVolume = CalculateCrossfadeVolume(itNoteOnEvent->Param.Note.Velocity); |
143 |
|
|
144 |
VolumeLeft = volume * pKeyInfo->PanLeft * AbstractEngine::PanCurve[64 - RgnInfo.Pan]; |
VolumeLeft = volume * pKeyInfo->PanLeft; |
145 |
VolumeRight = volume * pKeyInfo->PanRight * AbstractEngine::PanCurve[64 + RgnInfo.Pan]; |
VolumeRight = volume * pKeyInfo->PanRight; |
146 |
|
|
147 |
float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
// this rate is used for rather mellow volume fades |
148 |
|
const float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
149 |
|
// this rate is used for very fast volume fades |
150 |
|
const float quickRampRate = RTMath::Min(subfragmentRate, GetEngine()->SampleRate * 0.001f /* approx. 13ms */); |
151 |
CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate); |
CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate); |
152 |
|
|
153 |
VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate); |
VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate); |
154 |
PanLeftSmoother.trigger(pEngineChannel->GlobalPanLeft, subfragmentRate); |
NoteVolume.setCurrentValue(pNote ? pNote->Override.Volume : 1.f); |
155 |
PanRightSmoother.trigger(pEngineChannel->GlobalPanRight, subfragmentRate); |
NoteVolume.setDefaultDuration(pNote ? pNote->Override.VolumeTime : DEFAULT_NOTE_VOLUME_TIME_S); |
156 |
|
|
157 |
// Check if the sample needs disk streaming or is too short for that |
// Check if the sample needs disk streaming or is too short for that |
158 |
long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize; |
long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize; |
176 |
RAMLoop = (SmplInfo.HasLoops && (SmplInfo.LoopStart + SmplInfo.LoopLength) <= MaxRAMPos); |
RAMLoop = (SmplInfo.HasLoops && (SmplInfo.LoopStart + SmplInfo.LoopLength) <= MaxRAMPos); |
177 |
|
|
178 |
if (OrderNewStream()) return -1; |
if (OrderNewStream()) return -1; |
179 |
dmsg(4,("Disk voice launched (cached samples: %d, total Samples: %d, MaxRAMPos: %d, RAMLooping: %s)\n", cachedsamples, SmplInfo.TotalFrameCount, MaxRAMPos, (RAMLoop) ? "yes" : "no")); |
dmsg(4,("Disk voice launched (cached samples: %ld, total Samples: %d, MaxRAMPos: %lu, RAMLooping: %s)\n", cachedsamples, SmplInfo.TotalFrameCount, MaxRAMPos, (RAMLoop) ? "yes" : "no")); |
180 |
} |
} |
181 |
else { // RAM only voice |
else { // RAM only voice |
182 |
MaxRAMPos = cachedsamples; |
MaxRAMPos = cachedsamples; |
192 |
} |
} |
193 |
|
|
194 |
Pitch = CalculatePitchInfo(PitchBend); |
Pitch = CalculatePitchInfo(PitchBend); |
195 |
|
NotePitch.setCurrentValue(pNote ? pNote->Override.Pitch : 1.0f); |
196 |
|
NotePitch.setDefaultDuration(pNote ? pNote->Override.PitchTime : DEFAULT_NOTE_PITCH_TIME_S); |
197 |
|
NoteCutoff = (pNote) ? pNote->Override.Cutoff : 1.0f; |
198 |
|
NoteResonance = (pNote) ? pNote->Override.Resonance : 1.0f; |
199 |
|
|
200 |
// 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 |
201 |
const double velrelease = 1 / GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity); |
const double velrelease = 1 / GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity); |
202 |
|
|
203 |
if (GetSignalUnitRack() == NULL) { // setup EG 1 (VCA EG) |
if (pSignalUnitRack == NULL) { // setup EG 1 (VCA EG) |
204 |
// get current value of EG1 controller |
// get current value of EG1 controller |
205 |
double eg1controllervalue = GetEG1ControllerValue(itNoteOnEvent->Param.Note.Velocity); |
double eg1controllervalue = GetEG1ControllerValue(itNoteOnEvent->Param.Note.Velocity); |
206 |
|
|
207 |
// calculate influence of EG1 controller on EG1's parameters |
// calculate influence of EG1 controller on EG1's parameters |
208 |
EGInfo egInfo = CalculateEG1ControllerInfluence(eg1controllervalue); |
EGInfo egInfo = CalculateEG1ControllerInfluence(eg1controllervalue); |
209 |
|
|
210 |
|
if (pNote) { |
211 |
|
egInfo.Attack *= pNote->Override.Attack; |
212 |
|
egInfo.Decay *= pNote->Override.Decay; |
213 |
|
egInfo.Release *= pNote->Override.Release; |
214 |
|
} |
215 |
|
|
216 |
TriggerEG1(egInfo, velrelease, velocityAttenuation, GetEngine()->SampleRate, itNoteOnEvent->Param.Note.Velocity); |
TriggerEG1(egInfo, velrelease, velocityAttenuation, GetEngine()->SampleRate, itNoteOnEvent->Param.Note.Velocity); |
217 |
} else { |
} else { |
218 |
GetSignalUnitRack()->Trigger(); |
pSignalUnitRack->Trigger(); |
219 |
} |
} |
220 |
|
|
221 |
|
const uint8_t pan = (pSignalUnitRack) ? pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan) : MIDIPan; |
222 |
|
NotePanLeft = (pNote) ? AbstractEngine::PanCurveValueNorm(pNote->Override.Pan, 0 /*left*/ ) : 1.f; |
223 |
|
NotePanRight = (pNote) ? AbstractEngine::PanCurveValueNorm(pNote->Override.Pan, 1 /*right*/) : 1.f; |
224 |
|
PanLeftSmoother.trigger( |
225 |
|
AbstractEngine::PanCurve[128 - pan] * NotePanLeft, |
226 |
|
quickRampRate //NOTE: maybe we should have 2 separate pan smoothers, one for MIDI CC10 (with slow rate) and one for instrument script change_pan() calls (with fast rate) |
227 |
|
); |
228 |
|
PanRightSmoother.trigger( |
229 |
|
AbstractEngine::PanCurve[pan] * NotePanRight, |
230 |
|
quickRampRate //NOTE: maybe we should have 2 separate pan smoothers, one for MIDI CC10 (with slow rate) and one for instrument script change_pan() calls (with fast rate) |
231 |
|
); |
232 |
|
|
233 |
#ifdef CONFIG_INTERPOLATE_VOLUME |
#ifdef CONFIG_INTERPOLATE_VOLUME |
234 |
// setup initial volume in synthesis parameters |
// setup initial volume in synthesis parameters |
235 |
#ifdef CONFIG_PROCESS_MUTED_CHANNELS |
#ifdef CONFIG_PROCESS_MUTED_CHANNELS |
241 |
#else |
#else |
242 |
{ |
{ |
243 |
float finalVolume; |
float finalVolume; |
244 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
245 |
finalVolume = pEngineChannel->MidiVolume * crossfadeVolume * pEG1->getLevel(); |
finalVolume = pEngineChannel->MidiVolume * crossfadeVolume * pEG1->getLevel(); |
246 |
} else { |
} else { |
247 |
finalVolume = pEngineChannel->MidiVolume * crossfadeVolume * GetSignalUnitRack()->GetEndpointUnit()->GetVolume(); |
finalVolume = pEngineChannel->MidiVolume * crossfadeVolume * pSignalUnitRack->GetEndpointUnit()->GetVolume(); |
248 |
} |
} |
249 |
|
|
250 |
finalSynthesisParameters.fFinalVolumeLeft = finalVolume * VolumeLeft * pEngineChannel->GlobalPanLeft; |
finalSynthesisParameters.fFinalVolumeLeft = finalVolume * VolumeLeft * PanLeftSmoother.render(); |
251 |
finalSynthesisParameters.fFinalVolumeRight = finalVolume * VolumeRight * pEngineChannel->GlobalPanRight; |
finalSynthesisParameters.fFinalVolumeRight = finalVolume * VolumeRight * PanRightSmoother.render(); |
252 |
} |
} |
253 |
#endif |
#endif |
254 |
#endif |
#endif |
255 |
|
|
256 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
257 |
// setup EG 2 (VCF Cutoff EG) |
// setup EG 2 (VCF Cutoff EG) |
258 |
{ |
{ |
259 |
// get current value of EG2 controller |
// get current value of EG2 controller |
271 |
// if portamento mode is on, we dedicate EG3 purely for portamento, otherwise if portamento is off we do as told by the patch |
// if portamento mode is on, we dedicate EG3 purely for portamento, otherwise if portamento is off we do as told by the patch |
272 |
bool bPortamento = pEngineChannel->PortamentoMode && pEngineChannel->PortamentoPos >= 0.0f; |
bool bPortamento = pEngineChannel->PortamentoMode && pEngineChannel->PortamentoPos >= 0.0f; |
273 |
float eg3depth = (bPortamento) |
float eg3depth = (bPortamento) |
274 |
? RTMath::CentsToFreqRatio((pEngineChannel->PortamentoPos - (float) MIDIKey) * 100) |
? RTMath::CentsToFreqRatio((pEngineChannel->PortamentoPos - (float) MIDIKey()) * 100) |
275 |
: RTMath::CentsToFreqRatio(RgnInfo.EG3Depth); |
: RTMath::CentsToFreqRatio(RgnInfo.EG3Depth); |
276 |
float eg3time = (bPortamento) |
float eg3time = (bPortamento) |
277 |
? pEngineChannel->PortamentoTime |
? pEngineChannel->PortamentoTime |
332 |
VCFCutoffCtrl.controller = 0; |
VCFCutoffCtrl.controller = 0; |
333 |
VCFResonanceCtrl.controller = 0; |
VCFResonanceCtrl.controller = 0; |
334 |
} |
} |
335 |
|
|
336 |
|
const bool bEq = |
337 |
|
pSignalUnitRack != NULL && pSignalUnitRack->HasEq() && pEq->HasSupport(); |
338 |
|
|
339 |
|
if (bEq) { |
340 |
|
pEq->GetInChannelLeft()->Clear(); |
341 |
|
pEq->GetInChannelRight()->Clear(); |
342 |
|
pEq->RenderAudio(GetEngine()->pAudioOutputDevice->MaxSamplesPerCycle()); |
343 |
|
} |
344 |
|
|
345 |
return 0; // success |
return 0; // success |
346 |
} |
} |
359 |
* @param Skip - number of sample points to skip in output buffer |
* @param Skip - number of sample points to skip in output buffer |
360 |
*/ |
*/ |
361 |
void AbstractVoice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) { |
void AbstractVoice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) { |
362 |
|
bool delay = false; // Whether the voice playback should be delayed for this call |
363 |
|
|
364 |
|
if (pSignalUnitRack != NULL) { |
365 |
|
uint delaySteps = pSignalUnitRack->GetEndpointUnit()->DelayTrigger(); |
366 |
|
if (delaySteps > 0) { // delay on the endpoint unit means delay of the voice playback |
367 |
|
if (delaySteps >= Samples) { |
368 |
|
pSignalUnitRack->GetEndpointUnit()->DecreaseDelay(Samples); |
369 |
|
delay = true; |
370 |
|
} else { |
371 |
|
pSignalUnitRack->GetEndpointUnit()->DecreaseDelay(delaySteps); |
372 |
|
Samples -= delaySteps; |
373 |
|
Skip += delaySteps; |
374 |
|
} |
375 |
|
} |
376 |
|
} |
377 |
|
|
378 |
AbstractEngineChannel* pChannel = pEngineChannel; |
AbstractEngineChannel* pChannel = pEngineChannel; |
379 |
MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey); |
MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey()); |
380 |
|
|
381 |
const bool bVoiceRequiresDedicatedRouting = |
const bool bVoiceRequiresDedicatedRouting = |
382 |
pEngineChannel->GetFxSendCount() > 0 && |
pEngineChannel->GetFxSendCount() > 0 && |
383 |
(pMidiKeyInfo->ReverbSend || pMidiKeyInfo->ChorusSend); |
(pMidiKeyInfo->ReverbSend || pMidiKeyInfo->ChorusSend); |
384 |
|
|
385 |
|
const bool bEq = |
386 |
|
pSignalUnitRack != NULL && pSignalUnitRack->HasEq() && pEq->HasSupport(); |
387 |
|
|
388 |
if (bVoiceRequiresDedicatedRouting) { |
if (bEq) { |
389 |
|
pEq->GetInChannelLeft()->Clear(); |
390 |
|
pEq->GetInChannelRight()->Clear(); |
391 |
|
finalSynthesisParameters.pOutLeft = &pEq->GetInChannelLeft()->Buffer()[Skip]; |
392 |
|
finalSynthesisParameters.pOutRight = &pEq->GetInChannelRight()->Buffer()[Skip]; |
393 |
|
pSignalUnitRack->UpdateEqSettings(pEq); |
394 |
|
} else if (bVoiceRequiresDedicatedRouting) { |
395 |
finalSynthesisParameters.pOutLeft = &GetEngine()->pDedicatedVoiceChannelLeft->Buffer()[Skip]; |
finalSynthesisParameters.pOutLeft = &GetEngine()->pDedicatedVoiceChannelLeft->Buffer()[Skip]; |
396 |
finalSynthesisParameters.pOutRight = &GetEngine()->pDedicatedVoiceChannelRight->Buffer()[Skip]; |
finalSynthesisParameters.pOutRight = &GetEngine()->pDedicatedVoiceChannelRight->Buffer()[Skip]; |
397 |
} else { |
} else { |
402 |
|
|
403 |
RTList<Event>::Iterator itCCEvent = pChannel->pEvents->first(); |
RTList<Event>::Iterator itCCEvent = pChannel->pEvents->first(); |
404 |
RTList<Event>::Iterator itNoteEvent; |
RTList<Event>::Iterator itNoteEvent; |
405 |
GetFirstEventOnKey(MIDIKey, itNoteEvent); |
GetFirstEventOnKey(HostKey(), itNoteEvent); |
406 |
|
|
407 |
RTList<Event>::Iterator itGroupEvent; |
RTList<Event>::Iterator itGroupEvent; |
408 |
if (pGroupEvents) itGroupEvent = pGroupEvents->first(); |
if (pGroupEvents && !Orphan) itGroupEvent = pGroupEvents->first(); |
409 |
|
|
410 |
if (itTriggerEvent) { // skip events that happened before this voice was triggered |
if (itTriggerEvent) { // skip events that happened before this voice was triggered |
411 |
while (itCCEvent && itCCEvent->FragmentPos() <= Skip) ++itCCEvent; |
while (itCCEvent && itCCEvent->FragmentPos() <= Skip) ++itCCEvent; |
422 |
} |
} |
423 |
} |
} |
424 |
|
|
425 |
uint killPos; |
uint killPos = 0; |
426 |
if (itKillEvent) { |
if (itKillEvent) { |
427 |
int maxFadeOutPos = Samples - GetEngine()->GetMinFadeOutSamples(); |
int maxFadeOutPos = Samples - GetEngine()->GetMinFadeOutSamples(); |
428 |
if (maxFadeOutPos < 0) { |
if (maxFadeOutPos < 0) { |
431 |
// drivers that use Samples < MaxSamplesPerCycle). |
// drivers that use Samples < MaxSamplesPerCycle). |
432 |
// End the EG1 here, at pos 0, with a shorter max fade |
// End the EG1 here, at pos 0, with a shorter max fade |
433 |
// out time. |
// out time. |
434 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
435 |
pEG1->enterFadeOutStage(Samples / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
pEG1->enterFadeOutStage(Samples / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
436 |
} else { |
} else { |
437 |
// TODO: |
pSignalUnitRack->EnterFadeOutStage(Samples / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
438 |
} |
} |
439 |
itKillEvent = Pool<Event>::Iterator(); |
itKillEvent = Pool<Event>::Iterator(); |
440 |
} else { |
} else { |
450 |
fFinalCutoff = VCFCutoffCtrl.fvalue; |
fFinalCutoff = VCFCutoffCtrl.fvalue; |
451 |
fFinalResonance = VCFResonanceCtrl.fvalue; |
fFinalResonance = VCFResonanceCtrl.fvalue; |
452 |
|
|
453 |
// process MIDI control change and pitchbend events for this subfragment |
// process MIDI control change, aftertouch and pitchbend events for this subfragment |
454 |
processCCEvents(itCCEvent, iSubFragmentEnd); |
processCCEvents(itCCEvent, iSubFragmentEnd); |
455 |
|
uint8_t pan = MIDIPan; |
456 |
|
if (pSignalUnitRack != NULL) pan = pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan); |
457 |
|
|
458 |
|
PanLeftSmoother.update(AbstractEngine::PanCurve[128 - pan] * NotePanLeft); |
459 |
|
PanRightSmoother.update(AbstractEngine::PanCurve[pan] * NotePanRight); |
460 |
|
|
461 |
finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend; |
finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend * NotePitch.render(); |
462 |
float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render(); |
|
463 |
|
float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render() * NoteVolume.render(); |
464 |
#ifdef CONFIG_PROCESS_MUTED_CHANNELS |
#ifdef CONFIG_PROCESS_MUTED_CHANNELS |
465 |
if (pChannel->GetMute()) fFinalVolume = 0; |
if (pChannel->GetMute()) fFinalVolume = 0; |
466 |
#endif |
#endif |
468 |
// process transition events (note on, note off & sustain pedal) |
// process transition events (note on, note off & sustain pedal) |
469 |
processTransitionEvents(itNoteEvent, iSubFragmentEnd); |
processTransitionEvents(itNoteEvent, iSubFragmentEnd); |
470 |
processGroupEvents(itGroupEvent, iSubFragmentEnd); |
processGroupEvents(itGroupEvent, iSubFragmentEnd); |
471 |
|
|
472 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
473 |
// if the voice was killed in this subfragment, or if the |
// if the voice was killed in this subfragment, or if the |
474 |
// filter EG is finished, switch EG1 to fade out stage |
// filter EG is finished, switch EG1 to fade out stage |
475 |
if ((itKillEvent && killPos <= iSubFragmentEnd) || |
if ((itKillEvent && killPos <= iSubFragmentEnd) || |
512 |
|
|
513 |
// process low frequency oscillators |
// process low frequency oscillators |
514 |
if (bLFO1Enabled) fFinalVolume *= (1.0f - pLFO1->render()); |
if (bLFO1Enabled) fFinalVolume *= (1.0f - pLFO1->render()); |
515 |
if (bLFO2Enabled) fFinalCutoff *= pLFO2->render(); |
if (bLFO2Enabled) fFinalCutoff *= (1.0f - pLFO2->render()); |
516 |
if (bLFO3Enabled) finalSynthesisParameters.fFinalPitch *= RTMath::CentsToFreqRatio(pLFO3->render()); |
if (bLFO3Enabled) finalSynthesisParameters.fFinalPitch *= RTMath::CentsToFreqRatio(pLFO3->render()); |
517 |
} else { |
} else { |
518 |
// if the voice was killed in this subfragment, or if the |
// if the voice was killed in this subfragment, enter fade out stage |
519 |
// filter EG is finished, switch EG1 to fade out stage |
if (itKillEvent && killPos <= iSubFragmentEnd) { |
520 |
/*if ((itKillEvent && killPos <= iSubFragmentEnd) || |
pSignalUnitRack->EnterFadeOutStage(); |
521 |
(SYNTHESIS_MODE_GET_FILTER(SynthesisMode) && |
itKillEvent = Pool<Event>::Iterator(); |
522 |
pEG2->getSegmentType() == EG::segment_end)) { |
} |
523 |
|
|
524 |
|
// if the filter EG is finished, switch EG1 to fade out stage |
525 |
|
/*if (SYNTHESIS_MODE_GET_FILTER(SynthesisMode) && |
526 |
|
pEG2->getSegmentType() == EG::segment_end) { |
527 |
pEG1->enterFadeOutStage(); |
pEG1->enterFadeOutStage(); |
528 |
itKillEvent = Pool<Event>::Iterator(); |
itKillEvent = Pool<Event>::Iterator(); |
529 |
}*/ |
}*/ |
530 |
// TODO: ^^^ |
// TODO: ^^^ |
531 |
|
|
532 |
fFinalVolume *= GetSignalUnitRack()->GetEndpointUnit()->GetVolume(); |
fFinalVolume *= pSignalUnitRack->GetEndpointUnit()->GetVolume(); |
533 |
fFinalCutoff = GetSignalUnitRack()->GetEndpointUnit()->CalculateFilterCutoff(fFinalCutoff); |
fFinalCutoff = pSignalUnitRack->GetEndpointUnit()->CalculateFilterCutoff(fFinalCutoff); |
534 |
fFinalResonance = GetSignalUnitRack()->GetEndpointUnit()->CalculateResonance(fFinalResonance); |
fFinalResonance = pSignalUnitRack->GetEndpointUnit()->CalculateResonance(fFinalResonance); |
535 |
|
|
536 |
finalSynthesisParameters.fFinalPitch = |
finalSynthesisParameters.fFinalPitch = |
537 |
GetSignalUnitRack()->GetEndpointUnit()->CalculatePitch(finalSynthesisParameters.fFinalPitch); |
pSignalUnitRack->GetEndpointUnit()->CalculatePitch(finalSynthesisParameters.fFinalPitch); |
538 |
|
|
539 |
} |
} |
540 |
|
|
541 |
|
fFinalCutoff *= NoteCutoff; |
542 |
|
fFinalResonance *= NoteResonance; |
543 |
|
|
544 |
// limit the pitch so we don't read outside the buffer |
// limit the pitch so we don't read outside the buffer |
545 |
finalSynthesisParameters.fFinalPitch = RTMath::Min(finalSynthesisParameters.fFinalPitch, float(1 << CONFIG_MAX_PITCH)); |
finalSynthesisParameters.fFinalPitch = RTMath::Min(finalSynthesisParameters.fFinalPitch, float(1 << CONFIG_MAX_PITCH)); |
546 |
|
|
573 |
fFinalVolume * VolumeRight * PanRightSmoother.render(); |
fFinalVolume * VolumeRight * PanRightSmoother.render(); |
574 |
#endif |
#endif |
575 |
// render audio for one subfragment |
// render audio for one subfragment |
576 |
RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop); |
if (!delay) RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop); |
577 |
|
|
578 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
579 |
// stop the rendering if volume EG is finished |
// stop the rendering if volume EG is finished |
580 |
if (pEG1->getSegmentType() == EG::segment_end) break; |
if (pEG1->getSegmentType() == EG::segment_end) break; |
581 |
} else { |
} else { |
582 |
// stop the rendering if the endpoint unit is not active |
// stop the rendering if the endpoint unit is not active |
583 |
if (!GetSignalUnitRack()->GetEndpointUnit()->Active()) break; |
if (!pSignalUnitRack->GetEndpointUnit()->Active()) break; |
584 |
} |
} |
585 |
|
|
586 |
const double newPos = Pos + (iSubFragmentEnd - i) * finalSynthesisParameters.fFinalPitch; |
const double newPos = Pos + (iSubFragmentEnd - i) * finalSynthesisParameters.fFinalPitch; |
587 |
|
|
588 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
589 |
// increment envelopes' positions |
// increment envelopes' positions |
590 |
if (pEG1->active()) { |
if (pEG1->active()) { |
591 |
|
|
610 |
}*/ |
}*/ |
611 |
// TODO: ^^^ |
// TODO: ^^^ |
612 |
|
|
613 |
GetSignalUnitRack()->Increment(); |
if (!delay) pSignalUnitRack->Increment(); |
614 |
} |
} |
615 |
|
|
616 |
Pos = newPos; |
Pos = newPos; |
617 |
i = iSubFragmentEnd; |
i = iSubFragmentEnd; |
618 |
} |
} |
619 |
|
|
620 |
|
if (delay) return; |
621 |
|
|
622 |
if (bVoiceRequiresDedicatedRouting) { |
if (bVoiceRequiresDedicatedRouting) { |
623 |
|
if (bEq) { |
624 |
|
pEq->RenderAudio(Samples); |
625 |
|
pEq->GetOutChannelLeft()->CopyTo(GetEngine()->pDedicatedVoiceChannelLeft, Samples); |
626 |
|
pEq->GetOutChannelRight()->CopyTo(GetEngine()->pDedicatedVoiceChannelRight, Samples); |
627 |
|
} |
628 |
optional<float> effectSendLevels[2] = { |
optional<float> effectSendLevels[2] = { |
629 |
pMidiKeyInfo->ReverbSend, |
pMidiKeyInfo->ReverbSend, |
630 |
pMidiKeyInfo->ChorusSend |
pMidiKeyInfo->ChorusSend |
631 |
}; |
}; |
632 |
GetEngine()->RouteDedicatedVoiceChannels(pEngineChannel, effectSendLevels, Samples); |
GetEngine()->RouteDedicatedVoiceChannels(pEngineChannel, effectSendLevels, Samples); |
633 |
|
} else if (bEq) { |
634 |
|
pEq->RenderAudio(Samples); |
635 |
|
pEq->GetOutChannelLeft()->MixTo(pChannel->pChannelLeft, Samples); |
636 |
|
pEq->GetOutChannelRight()->MixTo(pChannel->pChannelRight, Samples); |
637 |
} |
} |
638 |
} |
} |
639 |
|
|
640 |
/** |
/** |
641 |
* Process given list of MIDI control change and pitch bend events for |
* Process given list of MIDI control change, aftertouch and pitch bend |
642 |
* the given time. |
* events for the given time. |
643 |
* |
* |
644 |
* @param itEvent - iterator pointing to the next event to be processed |
* @param itEvent - iterator pointing to the next event to be processed |
645 |
* @param End - youngest time stamp where processing should be stopped |
* @param End - youngest time stamp where processing should be stopped |
646 |
*/ |
*/ |
647 |
void AbstractVoice::processCCEvents(RTList<Event>::Iterator& itEvent, uint End) { |
void AbstractVoice::processCCEvents(RTList<Event>::Iterator& itEvent, uint End) { |
648 |
for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) { |
for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) { |
649 |
if (itEvent->Type == Event::type_control_change && itEvent->Param.CC.Controller) { // if (valid) MIDI control change event |
if ((itEvent->Type == Event::type_control_change || itEvent->Type == Event::type_channel_pressure) |
650 |
|
&& itEvent->Param.CC.Controller) // if (valid) MIDI control change event |
651 |
|
{ |
652 |
if (itEvent->Param.CC.Controller == VCFCutoffCtrl.controller) { |
if (itEvent->Param.CC.Controller == VCFCutoffCtrl.controller) { |
653 |
ProcessCutoffEvent(itEvent); |
ProcessCutoffEvent(itEvent); |
654 |
} |
} |
655 |
if (itEvent->Param.CC.Controller == VCFResonanceCtrl.controller) { |
if (itEvent->Param.CC.Controller == VCFResonanceCtrl.controller) { |
656 |
processResonanceEvent(itEvent); |
processResonanceEvent(itEvent); |
657 |
} |
} |
658 |
if (GetSignalUnitRack() == NULL) { |
if (itEvent->Param.CC.Controller == CTRL_TABLE_IDX_AFTERTOUCH || |
659 |
|
itEvent->Type == Event::type_channel_pressure) |
660 |
|
{ |
661 |
|
ProcessChannelPressureEvent(itEvent); |
662 |
|
} |
663 |
|
if (pSignalUnitRack == NULL) { |
664 |
if (itEvent->Param.CC.Controller == pLFO1->ExtController) { |
if (itEvent->Param.CC.Controller == pLFO1->ExtController) { |
665 |
pLFO1->update(itEvent->Param.CC.Value); |
pLFO1->updateByMIDICtrlValue(itEvent->Param.CC.Value); |
666 |
} |
} |
667 |
if (itEvent->Param.CC.Controller == pLFO2->ExtController) { |
if (itEvent->Param.CC.Controller == pLFO2->ExtController) { |
668 |
pLFO2->update(itEvent->Param.CC.Value); |
pLFO2->updateByMIDICtrlValue(itEvent->Param.CC.Value); |
669 |
} |
} |
670 |
if (itEvent->Param.CC.Controller == pLFO3->ExtController) { |
if (itEvent->Param.CC.Controller == pLFO3->ExtController) { |
671 |
pLFO3->update(itEvent->Param.CC.Value); |
pLFO3->updateByMIDICtrlValue(itEvent->Param.CC.Value); |
672 |
} |
} |
673 |
} |
} |
674 |
if (itEvent->Param.CC.Controller == 7) { // volume |
if (itEvent->Param.CC.Controller == 7) { // volume |
675 |
VolumeSmoother.update(AbstractEngine::VolumeCurve[itEvent->Param.CC.Value]); |
VolumeSmoother.update(AbstractEngine::VolumeCurve[itEvent->Param.CC.Value]); |
676 |
} else if (itEvent->Param.CC.Controller == 10) { // panpot |
} else if (itEvent->Param.CC.Controller == 10) { // panpot |
677 |
PanLeftSmoother.update(AbstractEngine::PanCurve[128 - itEvent->Param.CC.Value]); |
MIDIPan = CalculatePan(itEvent->Param.CC.Value); |
|
PanRightSmoother.update(AbstractEngine::PanCurve[itEvent->Param.CC.Value]); |
|
678 |
} |
} |
679 |
} else if (itEvent->Type == Event::type_pitchbend) { // if pitch bend event |
} else if (itEvent->Type == Event::type_pitchbend) { // if pitch bend event |
680 |
processPitchEvent(itEvent); |
processPitchEvent(itEvent); |
681 |
|
} else if (itEvent->Type == Event::type_note_pressure) { |
682 |
|
ProcessPolyphonicKeyPressureEvent(itEvent); |
683 |
} |
} |
684 |
|
|
685 |
ProcessCCEvent(itEvent); |
ProcessCCEvent(itEvent); |
686 |
if (GetSignalUnitRack() != NULL) { |
if (pSignalUnitRack != NULL) { |
687 |
GetSignalUnitRack()->ProcessCCEvent(itEvent); |
pSignalUnitRack->ProcessCCEvent(itEvent); |
688 |
} |
} |
689 |
} |
} |
690 |
} |
} |
704 |
} |
} |
705 |
|
|
706 |
/** |
/** |
707 |
* Process given list of MIDI note on, note off and sustain pedal events |
* Process given list of MIDI note on, note off, sustain pedal events and |
708 |
* for the given time. |
* note synthesis parameter events for the given time. |
709 |
* |
* |
710 |
* @param itEvent - iterator pointing to the next event to be processed |
* @param itEvent - iterator pointing to the next event to be processed |
711 |
* @param End - youngest time stamp where processing should be stopped |
* @param End - youngest time stamp where processing should be stopped |
714 |
for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) { |
for (; itEvent && itEvent->FragmentPos() <= End; ++itEvent) { |
715 |
// some voice types ignore note off |
// some voice types ignore note off |
716 |
if (!(Type & (Voice::type_one_shot | Voice::type_release_trigger | Voice::type_controller_triggered))) { |
if (!(Type & (Voice::type_one_shot | Voice::type_release_trigger | Voice::type_controller_triggered))) { |
717 |
if (itEvent->Type == Event::type_release) { |
if (itEvent->Type == Event::type_release_key) { |
718 |
EnterReleaseStage(); |
EnterReleaseStage(); |
719 |
} else if (itEvent->Type == Event::type_cancel_release) { |
} else if (itEvent->Type == Event::type_cancel_release_key) { |
720 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
721 |
pEG1->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
pEG1->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
722 |
pEG2->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
pEG2->update(EG::event_cancel_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
723 |
} else { |
} else { |
724 |
GetSignalUnitRack()->CancelRelease(); |
pSignalUnitRack->CancelRelease(); |
725 |
} |
} |
726 |
} |
} |
727 |
} |
} |
728 |
|
// process stop-note events (caused by built-in instrument script function note_off()) |
729 |
|
if (itEvent->Type == Event::type_release_note && pNote && |
730 |
|
pEngineChannel->pEngine->NoteByID( itEvent->Param.Note.ID ) == pNote) |
731 |
|
{ |
732 |
|
EnterReleaseStage(); |
733 |
|
} |
734 |
|
// process kill-note events (caused by built-in instrument script function fade_out()) |
735 |
|
if (itEvent->Type == Event::type_kill_note && pNote && |
736 |
|
pEngineChannel->pEngine->NoteByID( itEvent->Param.Note.ID ) == pNote) |
737 |
|
{ |
738 |
|
Kill(itEvent); |
739 |
|
} |
740 |
|
// process synthesis parameter events (caused by built-in realt-time instrument script functions) |
741 |
|
if (itEvent->Type == Event::type_note_synth_param && pNote && |
742 |
|
pEngineChannel->pEngine->NoteByID( itEvent->Param.NoteSynthParam.NoteID ) == pNote) |
743 |
|
{ |
744 |
|
switch (itEvent->Param.NoteSynthParam.Type) { |
745 |
|
case Event::synth_param_volume: |
746 |
|
NoteVolume.fadeTo(itEvent->Param.NoteSynthParam.AbsValue, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
747 |
|
break; |
748 |
|
case Event::synth_param_volume_time: |
749 |
|
NoteVolume.setDefaultDuration(itEvent->Param.NoteSynthParam.AbsValue); |
750 |
|
break; |
751 |
|
case Event::synth_param_pitch: |
752 |
|
NotePitch.fadeTo(itEvent->Param.NoteSynthParam.AbsValue, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
753 |
|
break; |
754 |
|
case Event::synth_param_pitch_time: |
755 |
|
NotePitch.setDefaultDuration(itEvent->Param.NoteSynthParam.AbsValue); |
756 |
|
break; |
757 |
|
case Event::synth_param_pan: |
758 |
|
NotePanLeft = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 0 /*left*/); |
759 |
|
NotePanRight = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 1 /*right*/); |
760 |
|
break; |
761 |
|
case Event::synth_param_cutoff: |
762 |
|
NoteCutoff = itEvent->Param.NoteSynthParam.AbsValue; |
763 |
|
break; |
764 |
|
case Event::synth_param_resonance: |
765 |
|
NoteResonance = itEvent->Param.NoteSynthParam.AbsValue; |
766 |
|
break; |
767 |
|
case Event::synth_param_amp_lfo_depth: |
768 |
|
pLFO1->setScriptDepthFactor(itEvent->Param.NoteSynthParam.AbsValue); |
769 |
|
break; |
770 |
|
case Event::synth_param_amp_lfo_freq: |
771 |
|
pLFO1->setScriptFrequencyFactor(itEvent->Param.NoteSynthParam.AbsValue, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
772 |
|
break; |
773 |
|
case Event::synth_param_pitch_lfo_depth: |
774 |
|
pLFO3->setScriptDepthFactor(itEvent->Param.NoteSynthParam.AbsValue); |
775 |
|
break; |
776 |
|
case Event::synth_param_pitch_lfo_freq: |
777 |
|
pLFO3->setScriptFrequencyFactor(itEvent->Param.NoteSynthParam.AbsValue, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
778 |
|
break; |
779 |
|
|
780 |
|
case Event::synth_param_attack: |
781 |
|
case Event::synth_param_decay: |
782 |
|
case Event::synth_param_release: |
783 |
|
break; // noop |
784 |
|
} |
785 |
|
} |
786 |
} |
} |
787 |
} |
} |
788 |
|
|
807 |
* @param itNoteOffEvent - event which causes this voice to die soon |
* @param itNoteOffEvent - event which causes this voice to die soon |
808 |
*/ |
*/ |
809 |
void AbstractVoice::UpdatePortamentoPos(Pool<Event>::Iterator& itNoteOffEvent) { |
void AbstractVoice::UpdatePortamentoPos(Pool<Event>::Iterator& itNoteOffEvent) { |
810 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
811 |
const float fFinalEG3Level = EG3.level(itNoteOffEvent->FragmentPos()); |
const float fFinalEG3Level = EG3.level(itNoteOffEvent->FragmentPos()); |
812 |
pEngineChannel->PortamentoPos = (float) MIDIKey + RTMath::FreqRatioToCents(fFinalEG3Level) * 0.01f; |
pEngineChannel->PortamentoPos = (float) MIDIKey() + RTMath::FreqRatioToCents(fFinalEG3Level) * 0.01f; |
813 |
} else { |
} else { |
814 |
// TODO: |
// TODO: |
815 |
} |
} |
836 |
|
|
837 |
Voice::PitchInfo AbstractVoice::CalculatePitchInfo(int PitchBend) { |
Voice::PitchInfo AbstractVoice::CalculatePitchInfo(int PitchBend) { |
838 |
PitchInfo pitch; |
PitchInfo pitch; |
839 |
double pitchbasecents = InstrInfo.FineTune + RgnInfo.FineTune + GetEngine()->ScaleTuning[MIDIKey % 12]; |
double pitchbasecents = InstrInfo.FineTune + RgnInfo.FineTune + GetEngine()->ScaleTuning[MIDIKey() % 12]; |
840 |
|
|
841 |
// GSt behaviour: maximum transpose up is 40 semitones. If |
// GSt behaviour: maximum transpose up is 40 semitones. If |
842 |
// MIDI key is more than 40 semitones above unity note, |
// MIDI key is more than 40 semitones above unity note, |
843 |
// the transpose is not done. |
// the transpose is not done. |
844 |
if (!SmplInfo.Unpitched && (MIDIKey - (int) RgnInfo.UnityNote) < 40) pitchbasecents += (MIDIKey - (int) RgnInfo.UnityNote) * 100; |
if (!SmplInfo.Unpitched && (MIDIKey() - (int) RgnInfo.UnityNote) < 40) pitchbasecents += (MIDIKey() - (int) RgnInfo.UnityNote) * 100; |
845 |
|
|
846 |
pitch.PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(SmplInfo.SampleRate) / double(GetEngine()->SampleRate)); |
pitch.PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(SmplInfo.SampleRate) / double(GetEngine()->SampleRate)); |
847 |
pitch.PitchBendRange = 1.0 / 8192.0 * 100.0 * InstrInfo.PitchbendRange; |
pitch.PitchBendRange = 1.0 / 8192.0 * 100.0 * InstrInfo.PitchbendRange; |
849 |
|
|
850 |
return pitch; |
return pitch; |
851 |
} |
} |
852 |
|
|
853 |
|
void AbstractVoice::onScaleTuningChanged() { |
854 |
|
PitchInfo pitch = this->Pitch; |
855 |
|
double pitchbasecents = InstrInfo.FineTune + RgnInfo.FineTune + GetEngine()->ScaleTuning[MIDIKey() % 12]; |
856 |
|
|
857 |
|
// GSt behaviour: maximum transpose up is 40 semitones. If |
858 |
|
// MIDI key is more than 40 semitones above unity note, |
859 |
|
// the transpose is not done. |
860 |
|
if (!SmplInfo.Unpitched && (MIDIKey() - (int) RgnInfo.UnityNote) < 40) pitchbasecents += (MIDIKey() - (int) RgnInfo.UnityNote) * 100; |
861 |
|
|
862 |
|
pitch.PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(SmplInfo.SampleRate) / double(GetEngine()->SampleRate)); |
863 |
|
this->Pitch = pitch; |
864 |
|
} |
865 |
|
|
866 |
double AbstractVoice::CalculateVolume(double velocityAttenuation) { |
double AbstractVoice::CalculateVolume(double velocityAttenuation) { |
867 |
// For 16 bit samples, we downscale by 32768 to convert from |
// For 16 bit samples, we downscale by 32768 to convert from |
874 |
// the volume of release triggered samples depends on note length |
// the volume of release triggered samples depends on note length |
875 |
if (Type & Voice::type_release_trigger) { |
if (Type & Voice::type_release_trigger) { |
876 |
float noteLength = float(GetEngine()->FrameTime + Delay - |
float noteLength = float(GetEngine()->FrameTime + Delay - |
877 |
GetNoteOnTime(MIDIKey) ) / GetEngine()->SampleRate; |
GetNoteOnTime(MIDIKey()) ) / GetEngine()->SampleRate; |
878 |
|
|
879 |
volume *= GetReleaseTriggerAttenuation(noteLength); |
volume *= GetReleaseTriggerAttenuation(noteLength); |
880 |
} |
} |
887 |
} |
} |
888 |
|
|
889 |
void AbstractVoice::EnterReleaseStage() { |
void AbstractVoice::EnterReleaseStage() { |
890 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
891 |
pEG1->update(EG::event_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
pEG1->update(EG::event_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
892 |
pEG2->update(EG::event_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
pEG2->update(EG::event_release, GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE); |
893 |
} else { |
} else { |
894 |
GetSignalUnitRack()->EnterReleaseStage(); |
pSignalUnitRack->EnterReleaseStage(); |
895 |
} |
} |
896 |
} |
} |
897 |
|
|
898 |
bool AbstractVoice::EG1Finished() { |
bool AbstractVoice::EG1Finished() { |
899 |
if (GetSignalUnitRack() == NULL) { |
if (pSignalUnitRack == NULL) { |
900 |
return pEG1->getSegmentType() == EG::segment_end; |
return pEG1->getSegmentType() == EG::segment_end; |
901 |
} else { |
} else { |
902 |
return !GetSignalUnitRack()->GetEndpointUnit()->Active(); |
return !pSignalUnitRack->GetEndpointUnit()->Active(); |
903 |
} |
} |
904 |
} |
} |
905 |
|
|