diff options
-rw-r--r-- | src/drumgizmo.cc | 5 | ||||
-rw-r--r-- | src/events.h | 1 | ||||
-rw-r--r-- | src/inputprocessor.cc | 3 |
3 files changed, 6 insertions, 3 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 81db5c5..5a201af 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -271,9 +271,10 @@ repeat: assert(t >= 0); assert(t < evt.buffer_size - evt.buffer_ptr); - if(evt.rampdownInProgress() && evt.rampdown_count > 0) + if(evt.rampdownInProgress() && evt.rampdown_offset < (evt.t + t) && + evt.rampdown_count > 0) { - scale = std::min((float)evt.rampdown_count/evt.ramp_length, 1.f); + scale = std::min((float)evt.rampdown_count / evt.ramp_length, 1.f); evt.rampdown_count--; } diff --git a/src/events.h b/src/events.h index c28283e..f43fbe2 100644 --- a/src/events.h +++ b/src/events.h @@ -101,6 +101,7 @@ public: void* instrument; int rampdown_count; int ramp_length; + std::size_t rampdown_offset{0}; float scale{1.0f}; }; diff --git a/src/inputprocessor.cc b/src/inputprocessor.cc index 1421d43..0adc389 100644 --- a/src/inputprocessor.cc +++ b/src/inputprocessor.cc @@ -138,7 +138,8 @@ bool InputProcessor::processOnset(event_t& event, // TODO: This must be configurable at some point... // ... perhaps even by instrument (ie. in the xml file) std::size_t ramp_length = (68./1000.)*settings.samplerate.load(); - event_sample.rampdown_count = event.offset + ramp_length; + event_sample.rampdown_count = ramp_length; + event_sample.rampdown_offset = event.offset; event_sample.ramp_length = ramp_length; } } |