From 48b545bcdf64adafeb5348df537272afc7e6e0f5 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Thu, 31 Aug 2023 11:24:47 -0400 Subject: [PATCH] Use ArrayVector in Sample --- src/core/Sample.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/Sample.cpp b/src/core/Sample.cpp index 26d5edbf6..03abc6ff7 100644 --- a/src/core/Sample.cpp +++ b/src/core/Sample.cpp @@ -27,6 +27,7 @@ #include #include #include +#include "ArrayVector.h" namespace lmms { @@ -384,7 +385,8 @@ auto Sample::playSampleRange(PlaybackState* state, sampleFrame* dst, int numFram numFrames / resampleRatio + (resampleRatio != 1.0f ? s_interpolationMargins[state->m_interpolationMode] : 0), m_endFrame - state->m_frameIndex); - auto buffer = std::vector(numFramesToCopy); + if (numFramesToCopy > 4096) { return false; } + auto buffer = ArrayVector(numFramesToCopy); copyBufferForward(buffer.data(), state->m_frameIndex, numFramesToCopy); auto resample @@ -402,7 +404,8 @@ auto Sample::playSampleRangeLoop(PlaybackState* state, sampleFrame* dst, int num const auto totalFramesToCopy = static_cast( numFrames / resampleRatio + (resampleRatio != 1.0f ? s_interpolationMargins[state->m_interpolationMode] : 0)); - auto buffer = std::vector(totalFramesToCopy); + if (totalFramesToCopy > 4096) { return false; } + auto buffer = ArrayVector(totalFramesToCopy); auto numFramesCopied = 0; while (numFramesCopied != totalFramesToCopy) @@ -437,7 +440,8 @@ auto Sample::playSampleRangePingPong(PlaybackState* state, sampleFrame* dst, int const auto totalFramesToCopy = static_cast( numFrames / resampleRatio + (resampleRatio != 1.0f ? s_interpolationMargins[state->m_interpolationMode] : 0)); - auto buffer = std::vector(totalFramesToCopy); + if (totalFramesToCopy > 4096) { return false; } + auto buffer = ArrayVector(totalFramesToCopy); auto numFramesCopied = 0; while (numFramesCopied != totalFramesToCopy)