From badd4bd7812e737300c4069fe85585810ff5bedf Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Sat, 25 Apr 2015 22:42:08 +0200 Subject: Fixed wrong indexing in local buffer caused when FRAMESIZE is not divisible by initial_sample_size. --- src/drumgizmo.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') 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. -- cgit v1.2.3