diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-04-26 09:18:05 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-20 13:24:29 +0100 |
commit | eead3fddcc07dedf2a56c0615f5d27c9db996efa (patch) | |
tree | be4f63372ecbe2ec5823eedb1182d21320e27800 /src/drumgizmo.cc | |
parent | 7d0ea0eee423056868f6d5c200725074d15921e7 (diff) |
Simplify (and slightly optimize) buffer counter code.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r-- | src/drumgizmo.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 890de59..fb4f042 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -434,25 +434,24 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) // not write over the end of the buffer. if(end > sz) end = sz; + size_t t = 0; // Internal buffer counter if(evt->rampdown == NO_RAMPDOWN) { #ifdef SSE size_t optend = ((end - n) / N) * N + n; - size_t t; for(; n < optend; n += N) { - t = (evt->t + buffer_offset) % evt->buffer_size; *(vNsf*)&(s[n]) += *(vNsf*)&(evt->buffer[t]); - evt->t += N; + t += N; } #endif for(; n < end; n++) { - s[n] += evt->buffer[ (evt->t + buffer_offset) % evt->buffer_size]; - evt->t++; + s[n] += evt->buffer[t]; + t++; } } else { // Ramp down in progress. for(; n < end && evt->rampdown; n++) { float scale = (float)evt->rampdown/(float)evt->ramp_start; - s[n] += evt->buffer[ (evt->t + buffer_offset) % evt->buffer_size] * scale; - evt->t++; + s[n] += evt->buffer[t] * scale; + t++; evt->rampdown--; } @@ -461,6 +460,7 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) cacheManager.close(evt->cache_id); } } + evt->t += t; // Add internal buffer counter to "global" event counter. if(evt->t >= af->size) { removeevent = true; |