aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-09-18 10:08:35 -0700
committerChris Robinson <[email protected]>2022-09-18 10:08:35 -0700
commitc52df6d78ab7131a543326cd2257f267036754e1 (patch)
treedf1caa87b299f47c9b0e8a1f32f7c9bae2604db8
parent0dd11a8e3c26674f943a57259d33ddbfd6081039 (diff)
Clear the buffer loop element when out of the loop range
-rw-r--r--core/voice.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/voice.cpp b/core/voice.cpp
index 7ca4ce73..b77a5eca 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -245,7 +245,7 @@ void LoadSamples(const al::span<float*> dstSamples, const size_t dstOffset, cons
#undef HANDLE_FMT
}
-void LoadBufferStatic(VoiceBufferItem *buffer, VoiceBufferItem *bufferLoopItem,
+void LoadBufferStatic(VoiceBufferItem *buffer, VoiceBufferItem *&bufferLoopItem,
const size_t dataPosInt, const FmtType sampleType, const FmtChannels sampleChannels,
const size_t srcStep, const size_t samplesToLoad, const al::span<float*> voiceSamples)
{
@@ -256,6 +256,8 @@ void LoadBufferStatic(VoiceBufferItem *buffer, VoiceBufferItem *bufferLoopItem,
/* If current pos is beyond the loop range, do not loop */
if(!bufferLoopItem || dataPosInt >= loopEnd)
{
+ bufferLoopItem = nullptr;
+
/* Load what's left to play from the buffer */
const size_t remaining{minz(samplesToLoad, buffer->mSampleLen-dataPosInt)};
LoadSamples(voiceSamples, 0, buffer->mSamples, dataPosInt, sampleType, sampleChannels,
@@ -645,7 +647,6 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo
prevSamples = mPrevSamples.data();
for(auto *chanbuffer : MixingSamples)
{
- /* Store the last source samples used for next time. */
std::copy_n(chanbuffer-MaxResamplerEdge+srcOffset, prevSamples->size(),
prevSamples->data());
++prevSamples;