diff options
author | Jonas Suhr Christensen <jsc@umbraculum.org> | 2015-04-25 22:42:08 +0200 |
---|---|---|
committer | Jonas Suhr Christensen <jsc@umbraculum.org> | 2015-04-25 22:42:08 +0200 |
commit | badd4bd7812e737300c4069fe85585810ff5bedf (patch) | |
tree | cde74dfe944bfffb59e70c9941076a74d12d0238 /src/drumgizmo.cc | |
parent | 18a5a05fd7a521a93a84cde9b3087a949856a0b9 (diff) |
Fixed wrong indexing in local buffer caused when FRAMESIZE is not divisible by initial_sample_size.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r-- | src/drumgizmo.cc | 14 |
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. |