diff --git a/src/sfizz/Config.h b/src/sfizz/Config.h index 3c724dad..023e7fed 100644 --- a/src/sfizz/Config.h +++ b/src/sfizz/Config.h @@ -126,6 +126,10 @@ namespace config { @brief Ratio to target under which smoothing is considered as completed */ static constexpr float smoothingShortcutThreshold = 5e-3; + // loop crossfade settings + static constexpr int loopXfadeCurve = 2; // 0: linear + // 1: use curves 5 & 6 + // 2: use S-shaped curve } // namespace config } // namespace sfz diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index 66c7bb1e..680f819e 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -588,8 +588,7 @@ void sfz::Voice::fillWithData(AudioSpan buffer) noexcept partitionStarts = absl::MakeSpan(const_cast(starts), 1); partitionTypes = absl::MakeSpan(const_cast(types), 1); numPartitions = 1; - } - else { + } else { for (auto& buf : partitionBuffers) { buf = resources.bufferPool.getIndexBuffer(numSamples); if (!buf) @@ -601,11 +600,6 @@ void sfz::Voice::fillWithData(AudioSpan buffer) noexcept // computed along with index processing below } - // loop crossfade settings - constexpr int loopXfadeUseCurves = 2; // 0: linear - // 1: use curves 5 & 6 - // 2: use S-shaped curve - // index preprocessing for loops if (isLooping) { int oldIndex {}; @@ -699,17 +693,17 @@ void sfz::Voice::fillWithData(AudioSpan buffer) noexcept { // compute out curve absl::Span xfCurve = xfTemp2->first(ptSize); - IF_CONSTEXPR (loopXfadeUseCurves == 2) { + IF_CONSTEXPR (config::loopXfadeCurve == 2) { const Curve& xfIn = getSCurve(); for (unsigned i = 0; i < ptSize; ++i) xfCurve[i] = xfIn.evalNormalized(1.0f - xfCurvePos[i]); } - else IF_CONSTEXPR (loopXfadeUseCurves == 1) { + else IF_CONSTEXPR (config::loopXfadeCurve == 1) { const Curve& xfOut = resources.curves.getCurve(6); for (unsigned i = 0; i < ptSize; ++i) xfCurve[i] = xfOut.evalNormalized(xfCurvePos[i]); } - else IF_CONSTEXPR (loopXfadeUseCurves == 0) { + else IF_CONSTEXPR (config::loopXfadeCurve == 0) { // TODO(jpc) vectorize this for (unsigned i = 0; i < ptSize; ++i) xfCurve[i] = clamp(1.0f - xfCurvePos[i], 0.0f, 1.0f); @@ -749,17 +743,17 @@ void sfz::Voice::fillWithData(AudioSpan buffer) noexcept // compute in curve absl::Span xfCurve = xfTemp2->first(applySize); - IF_CONSTEXPR (loopXfadeUseCurves == 2) { + IF_CONSTEXPR (config::loopXfadeCurve == 2) { const Curve& xfIn = getSCurve(); for (unsigned i = 0; i < applySize; ++i) xfCurve[i] = xfIn.evalNormalized(xfInCurvePos[i]); } - else IF_CONSTEXPR (loopXfadeUseCurves == 1) { + else IF_CONSTEXPR (config::loopXfadeCurve == 1) { const Curve& xfIn = resources.curves.getCurve(5); for (unsigned i = 0; i < applySize; ++i) xfCurve[i] = xfIn.evalNormalized(xfInCurvePos[i]); } - else IF_CONSTEXPR (loopXfadeUseCurves == 0) { + else IF_CONSTEXPR (config::loopXfadeCurve == 0) { // TODO(jpc) vectorize this for (unsigned i = 0; i < applySize; ++i) xfCurve[i] = clamp(xfInCurvePos[i], 0.0f, 1.0f);