summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mdaPianoVoice.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mdaPianoVoice.cpp b/src/mdaPianoVoice.cpp
index 2b70c3e..08a3aa4 100644
--- a/src/mdaPianoVoice.cpp
+++ b/src/mdaPianoVoice.cpp
@@ -192,7 +192,9 @@ void mdaPianoVoice::render(uint32_t from, uint32_t to) {
frac += delta; // integer-based linear interpolation
pos += frac >> 16;
frac &= 0xFFFF; // why AND it with all ones?
- if(pos > end) pos -= loop; // jump back to loop sample
+ if (pos >= end) {
+ pos -= loop; // jump to loop point in sample
+ }
#ifdef PIANO
i = samples[sample_index].buffer[pos];