diff --git a/src/sfizz/ModifierHelpers.h b/src/sfizz/ModifierHelpers.h index 5ea57c02..609b16ff 100644 --- a/src/sfizz/ModifierHelpers.h +++ b/src/sfizz/ModifierHelpers.h @@ -271,8 +271,8 @@ void pitchBendEnvelope(const EventVector& events, absl::Span envelope, F& template void linearModifier(const sfz::Resources& resources, absl::Span span, const sfz::CCData& ccData, F&& lambda) { - const auto events = resources.midiState.getCCEvents(ccData.cc); - const auto curve = resources.curves.getCurve(ccData.data.curve); + const auto& events = resources.midiState.getCCEvents(ccData.cc); + const auto& curve = resources.curves.getCurve(ccData.data.curve); if (ccData.data.step == 0.0f) { linearEnvelope(events, span, [&ccData, &curve, &lambda](float x) { return lambda(curve.evalNormalized(x) * ccData.data.value); @@ -301,8 +301,8 @@ void linearModifier(const sfz::Resources& resources, absl::Span span, con template void multiplicativeModifier(const sfz::Resources& resources, absl::Span span, const sfz::CCData& ccData, F&& lambda) { - const auto events = resources.midiState.getCCEvents(ccData.cc); - const auto curve = resources.curves.getCurve(ccData.data.curve); + const auto& events = resources.midiState.getCCEvents(ccData.cc); + const auto& curve = resources.curves.getCurve(ccData.data.curve); if (ccData.data.step == 0.0f) { multiplicativeEnvelope(events, span, [&ccData, &curve, &lambda](float x) { return lambda(curve.evalNormalized(x) * ccData.data.value); diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index 6dff257b..771900d1 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -142,7 +142,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, float value, ASSERT(modifierSmoothers[modId].size() >= region->modifiers[modId].size()); forEachWithSmoother(modId, [modId, this](const CCData& mod, Smoother& smoother) { const auto ccValue = resources.midiState.getCCValue(mod.cc); - const auto curve = resources.curves.getCurve(mod.data.curve); + const auto& curve = resources.curves.getCurve(mod.data.curve); const auto finalValue = curve.evalNormalized(ccValue) * mod.data.value; switch (modId) { case Mod::volume: @@ -347,7 +347,7 @@ void sfz::Voice::applyCrossfades(absl::Span modulationSpan) noexcept bool canShortcut = true; for (const auto& mod : region->crossfadeCCInRange) { - const auto events = resources.midiState.getCCEvents(mod.cc); + const auto& events = resources.midiState.getCCEvents(mod.cc); canShortcut &= (events.size() == 1); linearEnvelope(events, *tempSpan, [&](float x) { return crossfadeIn(mod.data, x, xfCurve); @@ -356,7 +356,7 @@ void sfz::Voice::applyCrossfades(absl::Span modulationSpan) noexcept } for (const auto& mod : region->crossfadeCCOutRange) { - const auto events = resources.midiState.getCCEvents(mod.cc); + const auto& events = resources.midiState.getCCEvents(mod.cc); canShortcut &= (events.size() == 1); linearEnvelope(events, *tempSpan, [&](float x) { return crossfadeOut(mod.data, x, xfCurve);