diff options
author | rekado <rekado@elephly.net> | 2013-07-29 22:03:12 +0800 |
---|---|---|
committer | rekado <rekado@elephly.net> | 2013-07-29 22:03:12 +0800 |
commit | 9351e497529befc15cbe28a77200c3c716629941 (patch) | |
tree | 17d6e05002c3ea2275dcc45da968acbb5cca3fd5 | |
parent | cda788f4ba91a4524aa1c08476c07621c8e96665 (diff) |
fix off-by-one error
-rw-r--r-- | src/mdaPianoVoice.cpp | 4 |
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]; |