summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.