diff --git a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp index 6adec04448..a987d7f575 100644 --- a/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp +++ b/modules/juce_audio_basics/sources/juce_MemoryAudioSource.cpp @@ -49,7 +49,8 @@ void MemoryAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferT auto max = 0, pos = 0; auto n = buffer.getNumSamples(), m = bufferToFill.numSamples; - for (auto i = position; (i < n || isLooping) && (pos < m); i += max) + int i; + for (i = position; (i < n || isLooping) && (pos < m); i += max) { max = jmin (m - pos, n - (i % n)); @@ -65,6 +66,8 @@ void MemoryAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& bufferT if (pos < m) dst.clear (bufferToFill.startSample + pos, m - pos); + + position = (i % n); } } // namespace juce