summaryrefslogtreecommitdiff
path: root/src/drumgizmo.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2018-08-02 10:49:39 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2018-08-02 14:06:34 +0200
commit84730760698833df09eb8b082a5473be5fc85c85 (patch)
tree18db88656718463c3af7349637c613cf9c889e5d /src/drumgizmo.cc
parente39d82f5a06db9d4c4c505d30c4ac116037e1399 (diff)
Fix rampdown issue and clean up a bit while at it.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r--src/drumgizmo.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index d30952e..2d3e410 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -319,9 +319,8 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t* s, size_t sz)
}
size_t t = 0; // Internal buffer counter
- if(evt.rampdown == NO_RAMPDOWN)
+ if(!evt.rampdownInProgress())
{
-
#ifdef SSE
size_t optend = ((end - n) / N) * N + n;
@@ -352,19 +351,19 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t* s, size_t sz)
}
else
{ // Ramp down in progress.
- for(; (n < end) && (t < evt.buffer_size) && evt.rampdown; ++n)
+ for(; (n < end) && (t < evt.buffer_size) && evt.rampdown_count; ++n)
{
- float scale = (float)evt.rampdown/(float)evt.ramp_start;
+ float scale = std::min((float)evt.rampdown_count/evt.ramp_length, 1.f);
s[n] += evt.buffer[t] * evt.scale * scale;
++t;
- evt.rampdown--;
+ evt.rampdown_count--;
}
}
// Add internal buffer counter to "global" event counter.
evt.t += evt.buffer_size;
- if((evt.t < af.size) && (evt.rampdown != 0))
+ if((evt.t < af.size) && (evt.rampdown_count != 0))
{
evt.buffer = audio_cache.next(evt.cache_id, evt.buffer_size);
}