From f3fbc1e3277a86538975f69b7b7c0389a9134139 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Wed, 23 Sep 2020 14:02:29 +0200 Subject: [PATCH] Fix the unison osc broken after alignment work --- src/sfizz/Voice.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index ae49816a..bc952482 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -693,8 +693,9 @@ void sfz::Voice::fillWithGenerator(AudioSpan buffer) noexcept else if (oscillatorMode <= 0 && oscillatorMulti >= 3) { // unison oscillator auto tempSpan = resources.bufferPool.getBuffer(numFrames); - auto temp2Span = resources.bufferPool.getBuffer(numFrames); - if (!tempSpan || !temp2Span) + auto tempLeftSpan = resources.bufferPool.getBuffer(numFrames); + auto tempRightSpan = resources.bufferPool.getBuffer(numFrames); + if (!tempSpan || !tempLeftSpan || !tempRightSpan) return; const float* detuneMod = resources.modMatrix.getModulation(oscillatorDetuneTarget); @@ -708,11 +709,18 @@ void sfz::Voice::fillWithGenerator(AudioSpan buffer) noexcept applyGain1(waveDetuneRatio[u], *detuneSpan); } osc.processModulated(frequencies->data(), detuneSpan->data(), tempSpan->data(), numFrames); - multiplyAdd1(waveLeftGain[u], *tempSpan, *temp2Span); - copy(*temp2Span, leftSpan); - multiplyAdd1(waveRightGain[u], *tempSpan, *temp2Span); - copy(*temp2Span, rightSpan); + if (u == 0) { + applyGain1(waveLeftGain[u], *tempSpan, *tempLeftSpan); + applyGain1(waveRightGain[u], *tempSpan, *tempRightSpan); + } + else { + multiplyAdd1(waveLeftGain[u], *tempSpan, *tempLeftSpan); + multiplyAdd1(waveRightGain[u], *tempSpan, *tempRightSpan); + } } + + copy(*tempLeftSpan, leftSpan); + copy(*tempRightSpan, rightSpan); } else { // modulated oscillator