summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-04-26 09:18:05 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2015-04-26 09:18:05 +0200
commitc91ae2624f3d3c003c6b2065f3cc128b1b039801 (patch)
treeedb3a8fb36db108b4cc226353849222c2e8d0e9e /src
parent779c392e4065027859741dc3dc44222098fdafb7 (diff)
Simplify (and slightly optimize) buffer counter code.
Diffstat (limited to 'src')
-rw-r--r--src/drumgizmo.cc14
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;