Use linear xfade curves
This commit is contained in:
parent
fda4b5931c
commit
453d489d4a
1 changed files with 23 additions and 6 deletions
|
|
@ -625,6 +625,9 @@ void sfz::Voice::fillWithData(AudioSpan<float> buffer) noexcept
|
||||||
// computed along with index processing below
|
// computed along with index processing below
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// loop crossfade settings
|
||||||
|
constexpr bool loopXfadeUseCurves = false; // 0: linear, 1: use curves 5 & 6
|
||||||
|
|
||||||
// index preprocessing for loops
|
// index preprocessing for loops
|
||||||
if (isLooping) {
|
if (isLooping) {
|
||||||
int oldIndex {};
|
int oldIndex {};
|
||||||
|
|
@ -711,10 +714,17 @@ void sfz::Voice::fillWithData(AudioSpan<float> buffer) noexcept
|
||||||
// -> fade out signal nearing the loop end
|
// -> fade out signal nearing the loop end
|
||||||
{
|
{
|
||||||
// compute out curve
|
// compute out curve
|
||||||
const Curve& xfOut = resources.curves.getCurve(6);
|
|
||||||
absl::Span<float> xfCurve = xfadeTemp[1]->first(ptSize);
|
absl::Span<float> xfCurve = xfadeTemp[1]->first(ptSize);
|
||||||
for (unsigned i = 0; i < ptSize; ++i)
|
IF_CONSTEXPR (loopXfadeUseCurves) {
|
||||||
xfCurve[i] = xfOut.evalNormalized(xfCoeff[i]);
|
const Curve& xfOut = resources.curves.getCurve(6);
|
||||||
|
for (unsigned i = 0; i < ptSize; ++i)
|
||||||
|
xfCurve[i] = xfOut.evalNormalized(xfCoeff[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO(jpc) vectorize this
|
||||||
|
for (unsigned i = 0; i < ptSize; ++i)
|
||||||
|
xfCurve[i] = clamp(1.0f - xfCoeff[i], 0.0f, 1.0f);
|
||||||
|
}
|
||||||
// apply out curve
|
// apply out curve
|
||||||
if (0)
|
if (0)
|
||||||
ptBuffer.applyGain(xfCurve);
|
ptBuffer.applyGain(xfCurve);
|
||||||
|
|
@ -752,10 +762,17 @@ void sfz::Voice::fillWithData(AudioSpan<float> buffer) noexcept
|
||||||
AudioSpan<float> xfInBuffer = ptBuffer.subspan(applyOffset);
|
AudioSpan<float> xfInBuffer = ptBuffer.subspan(applyOffset);
|
||||||
|
|
||||||
// compute in curve
|
// compute in curve
|
||||||
const Curve& xfIn = resources.curves.getCurve(5);
|
|
||||||
absl::Span<float> xfCurve = xfadeTemp[1]->first(applySize);
|
absl::Span<float> xfCurve = xfadeTemp[1]->first(applySize);
|
||||||
for (unsigned i = 0; i < applySize; ++i)
|
IF_CONSTEXPR (loopXfadeUseCurves) {
|
||||||
xfCurve[i] = xfIn.evalNormalized(xfInCoeff[i]);
|
const Curve& xfIn = resources.curves.getCurve(5);
|
||||||
|
for (unsigned i = 0; i < applySize; ++i)
|
||||||
|
xfCurve[i] = xfIn.evalNormalized(xfInCoeff[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO(jpc) vectorize this
|
||||||
|
for (unsigned i = 0; i < applySize; ++i)
|
||||||
|
xfCurve[i] = clamp(xfInCoeff[i], 0.0f, 1.0f);
|
||||||
|
}
|
||||||
// apply in curve
|
// apply in curve
|
||||||
fillInterpolatedWithQuality<true>(
|
fillInterpolatedWithQuality<true>(
|
||||||
source, xfInBuffer, xfInIndices, *coeffs, xfCurve, quality);
|
source, xfInBuffer, xfInIndices, *coeffs, xfCurve, quality);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue