summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-07-29 22:03:12 +0800
committerrekado <rekado@elephly.net>2013-07-29 22:03:12 +0800
commit9351e497529befc15cbe28a77200c3c716629941 (patch)
tree17d6e05002c3ea2275dcc45da968acbb5cca3fd5
parentcda788f4ba91a4524aa1c08476c07621c8e96665 (diff)
fix off-by-one error
-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];