43 |
|
|
44 |
finalSynthesisParameters.filterLeft.Reset(); |
finalSynthesisParameters.filterLeft.Reset(); |
45 |
finalSynthesisParameters.filterRight.Reset(); |
finalSynthesisParameters.filterRight.Reset(); |
46 |
|
|
47 |
|
pEq = NULL; |
48 |
|
bEqSupport = false; |
49 |
} |
} |
50 |
|
|
51 |
AbstractVoice::~AbstractVoice() { |
AbstractVoice::~AbstractVoice() { |
52 |
if (pLFO1) delete pLFO1; |
if (pLFO1) delete pLFO1; |
53 |
if (pLFO2) delete pLFO2; |
if (pLFO2) delete pLFO2; |
54 |
if (pLFO3) delete pLFO3; |
if (pLFO3) delete pLFO3; |
55 |
|
|
56 |
|
if(pEq != NULL) delete pEq; |
57 |
|
} |
58 |
|
|
59 |
|
void AbstractVoice::CreateEq() { |
60 |
|
if(!bEqSupport) return; |
61 |
|
if(pEq != NULL) delete pEq; |
62 |
|
pEq = new EqSupport; |
63 |
|
pEq->InitEffect(GetEngine()->pAudioOutputDevice); |
64 |
} |
} |
65 |
|
|
66 |
/** |
/** |
306 |
VCFCutoffCtrl.controller = 0; |
VCFCutoffCtrl.controller = 0; |
307 |
VCFResonanceCtrl.controller = 0; |
VCFResonanceCtrl.controller = 0; |
308 |
} |
} |
309 |
|
|
310 |
|
const bool bEq = |
311 |
|
pSignalUnitRack != NULL && pSignalUnitRack->HasEq() && pEq->HasSupport(); |
312 |
|
|
313 |
|
if (bEq) { |
314 |
|
pEq->GetInChannelLeft()->Clear(); |
315 |
|
pEq->GetInChannelRight()->Clear(); |
316 |
|
pEq->RenderAudio(GetEngine()->pAudioOutputDevice->MaxSamplesPerCycle()); |
317 |
|
} |
318 |
|
|
319 |
return 0; // success |
return 0; // success |
320 |
} |
} |
333 |
* @param Skip - number of sample points to skip in output buffer |
* @param Skip - number of sample points to skip in output buffer |
334 |
*/ |
*/ |
335 |
void AbstractVoice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) { |
void AbstractVoice::Synthesize(uint Samples, sample_t* pSrc, uint Skip) { |
336 |
|
bool delay = false; // Whether the voice playback should be delayed for this call |
337 |
|
|
338 |
|
if (pSignalUnitRack != NULL) { |
339 |
|
uint delaySteps = pSignalUnitRack->GetEndpointUnit()->DelayTrigger(); |
340 |
|
if (delaySteps > 0) { // delay on the endpoint unit means delay of the voice playback |
341 |
|
if (delaySteps >= Samples) { |
342 |
|
pSignalUnitRack->GetEndpointUnit()->DecreaseDelay(Samples); |
343 |
|
delay = true; |
344 |
|
} else { |
345 |
|
pSignalUnitRack->GetEndpointUnit()->DecreaseDelay(delaySteps); |
346 |
|
Samples -= delaySteps; |
347 |
|
Skip += delaySteps; |
348 |
|
} |
349 |
|
} |
350 |
|
} |
351 |
|
|
352 |
AbstractEngineChannel* pChannel = pEngineChannel; |
AbstractEngineChannel* pChannel = pEngineChannel; |
353 |
MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey); |
MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey); |
354 |
|
|
355 |
const bool bVoiceRequiresDedicatedRouting = |
const bool bVoiceRequiresDedicatedRouting = |
356 |
pEngineChannel->GetFxSendCount() > 0 && |
pEngineChannel->GetFxSendCount() > 0 && |
357 |
(pMidiKeyInfo->ReverbSend || pMidiKeyInfo->ChorusSend); |
(pMidiKeyInfo->ReverbSend || pMidiKeyInfo->ChorusSend); |
358 |
|
|
359 |
|
const bool bEq = |
360 |
|
pSignalUnitRack != NULL && pSignalUnitRack->HasEq() && pEq->HasSupport(); |
361 |
|
|
362 |
if (bVoiceRequiresDedicatedRouting) { |
if (bEq) { |
363 |
|
pEq->GetInChannelLeft()->Clear(); |
364 |
|
pEq->GetInChannelRight()->Clear(); |
365 |
|
finalSynthesisParameters.pOutLeft = &pEq->GetInChannelLeft()->Buffer()[Skip]; |
366 |
|
finalSynthesisParameters.pOutRight = &pEq->GetInChannelRight()->Buffer()[Skip]; |
367 |
|
pSignalUnitRack->UpdateEqSettings(pEq); |
368 |
|
} else if (bVoiceRequiresDedicatedRouting) { |
369 |
finalSynthesisParameters.pOutLeft = &GetEngine()->pDedicatedVoiceChannelLeft->Buffer()[Skip]; |
finalSynthesisParameters.pOutLeft = &GetEngine()->pDedicatedVoiceChannelLeft->Buffer()[Skip]; |
370 |
finalSynthesisParameters.pOutRight = &GetEngine()->pDedicatedVoiceChannelRight->Buffer()[Skip]; |
finalSynthesisParameters.pOutRight = &GetEngine()->pDedicatedVoiceChannelRight->Buffer()[Skip]; |
371 |
} else { |
} else { |
441 |
// process transition events (note on, note off & sustain pedal) |
// process transition events (note on, note off & sustain pedal) |
442 |
processTransitionEvents(itNoteEvent, iSubFragmentEnd); |
processTransitionEvents(itNoteEvent, iSubFragmentEnd); |
443 |
processGroupEvents(itGroupEvent, iSubFragmentEnd); |
processGroupEvents(itGroupEvent, iSubFragmentEnd); |
444 |
|
|
445 |
if (pSignalUnitRack == NULL) { |
if (pSignalUnitRack == NULL) { |
446 |
// if the voice was killed in this subfragment, or if the |
// if the voice was killed in this subfragment, or if the |
447 |
// filter EG is finished, switch EG1 to fade out stage |
// filter EG is finished, switch EG1 to fade out stage |
488 |
if (bLFO2Enabled) fFinalCutoff *= pLFO2->render(); |
if (bLFO2Enabled) fFinalCutoff *= pLFO2->render(); |
489 |
if (bLFO3Enabled) finalSynthesisParameters.fFinalPitch *= RTMath::CentsToFreqRatio(pLFO3->render()); |
if (bLFO3Enabled) finalSynthesisParameters.fFinalPitch *= RTMath::CentsToFreqRatio(pLFO3->render()); |
490 |
} else { |
} else { |
491 |
// if the voice was killed in this subfragment, or if the |
// if the voice was killed in this subfragment, enter fade out stage |
492 |
// filter EG is finished, switch EG1 to fade out stage |
if (itKillEvent && killPos <= iSubFragmentEnd) { |
493 |
/*if ((itKillEvent && killPos <= iSubFragmentEnd) || |
pSignalUnitRack->EnterFadeOutStage(); |
494 |
(SYNTHESIS_MODE_GET_FILTER(SynthesisMode) && |
itKillEvent = Pool<Event>::Iterator(); |
495 |
pEG2->getSegmentType() == EG::segment_end)) { |
} |
496 |
|
|
497 |
|
// if the filter EG is finished, switch EG1 to fade out stage |
498 |
|
/*if (SYNTHESIS_MODE_GET_FILTER(SynthesisMode) && |
499 |
|
pEG2->getSegmentType() == EG::segment_end) { |
500 |
pEG1->enterFadeOutStage(); |
pEG1->enterFadeOutStage(); |
501 |
itKillEvent = Pool<Event>::Iterator(); |
itKillEvent = Pool<Event>::Iterator(); |
502 |
}*/ |
}*/ |
543 |
fFinalVolume * VolumeRight * PanRightSmoother.render(); |
fFinalVolume * VolumeRight * PanRightSmoother.render(); |
544 |
#endif |
#endif |
545 |
// render audio for one subfragment |
// render audio for one subfragment |
546 |
RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop); |
if (!delay) RunSynthesisFunction(SynthesisMode, &finalSynthesisParameters, &loop); |
547 |
|
|
548 |
if (pSignalUnitRack == NULL) { |
if (pSignalUnitRack == NULL) { |
549 |
// stop the rendering if volume EG is finished |
// stop the rendering if volume EG is finished |
580 |
}*/ |
}*/ |
581 |
// TODO: ^^^ |
// TODO: ^^^ |
582 |
|
|
583 |
pSignalUnitRack->Increment(); |
if (!delay) pSignalUnitRack->Increment(); |
584 |
} |
} |
585 |
|
|
586 |
Pos = newPos; |
Pos = newPos; |
587 |
i = iSubFragmentEnd; |
i = iSubFragmentEnd; |
588 |
} |
} |
589 |
|
|
590 |
|
if (delay) return; |
591 |
|
|
592 |
if (bVoiceRequiresDedicatedRouting) { |
if (bVoiceRequiresDedicatedRouting) { |
593 |
|
if (bEq) { |
594 |
|
pEq->RenderAudio(Samples); |
595 |
|
pEq->GetOutChannelLeft()->CopyTo(GetEngine()->pDedicatedVoiceChannelLeft, Samples); |
596 |
|
pEq->GetOutChannelRight()->CopyTo(GetEngine()->pDedicatedVoiceChannelRight, Samples); |
597 |
|
} |
598 |
optional<float> effectSendLevels[2] = { |
optional<float> effectSendLevels[2] = { |
599 |
pMidiKeyInfo->ReverbSend, |
pMidiKeyInfo->ReverbSend, |
600 |
pMidiKeyInfo->ChorusSend |
pMidiKeyInfo->ChorusSend |
601 |
}; |
}; |
602 |
GetEngine()->RouteDedicatedVoiceChannels(pEngineChannel, effectSendLevels, Samples); |
GetEngine()->RouteDedicatedVoiceChannels(pEngineChannel, effectSendLevels, Samples); |
603 |
|
} else if (bEq) { |
604 |
|
pEq->RenderAudio(Samples); |
605 |
|
pEq->GetOutChannelLeft()->MixTo(pChannel->pChannelLeft, Samples); |
606 |
|
pEq->GetOutChannelRight()->MixTo(pChannel->pChannelRight, Samples); |
607 |
} |
} |
608 |
} |
} |
609 |
|
|