summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2015-04-25 22:42:08 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-20 13:24:29 +0100
commita9a47aa589db280d957242b1af48c0c9db4f14a4 (patch)
tree2808014cb7dc1eee3dc738372485f8f2c8731a14 /src
parent08199d82515af562bbdd67042a842b6922720de5 (diff)
Fixed wrong indexing in local buffer caused when FRAMESIZE is not divisible by initial_sample_size.
Diffstat (limited to 'src')
-rw-r--r--src/drumgizmo.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 6c40748..dd3c08d 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -405,6 +405,8 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
continue;
}
+ bool initial = evt->cache_id == CACHE_NOID? 1 : 0;
+
if(evt->cache_id == CACHE_NOID) {
size_t initial_chunksize = (pos + sz) - evt->offset;
evt->buffer =
@@ -417,8 +419,10 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
size_t n = 0; // default start point is 0.
- // If we are not at offset 0 in current buffer:
- if(evt->offset > (size_t)pos) n = evt->offset - pos;
+ if(initial) {
+ // If we are not at offset 0 in current buffer:
+ if(evt->offset > (size_t)pos) n = evt->offset - pos;
+ }
size_t end = sz; // default end point is the end of the buffer.
@@ -430,6 +434,7 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
if(end > sz) end = sz;
if(evt->rampdown == NO_RAMPDOWN) {
+
#ifdef SSE
size_t optend = ((end - n) / N) * N + n;
size_t t;
@@ -440,7 +445,10 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
}
#endif
for(; n < end; n++) {
- s[n] += evt->buffer[evt->t % evt->buffer_size];
+ if(initial)
+ s[n] += evt->buffer[evt->t % evt->buffer_size];
+ else
+ s[n] += evt->buffer[(evt->t + evt->offset) % evt->buffer_size];
evt->t++;
}
} else { // Ramp down in progress.