diff options
author | André Nusser <andre.nusser@googlemail.com> | 2019-07-22 22:15:46 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2019-07-22 22:15:46 +0200 |
commit | 4e83b447020c8ddce7e8b4f2b591dc42585df138 (patch) | |
tree | 85484bd308a0cd5379fe6477c216b55e2d0d5490 /src/staminafilter.cc | |
parent | bf75eb9f0f11d4eae23dbb031f088877dfd5c125 (diff) |
Fix humanizer bug and simplify stamina filter code.
Diffstat (limited to 'src/staminafilter.cc')
-rw-r--r-- | src/staminafilter.cc | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/staminafilter.cc b/src/staminafilter.cc index a8f6a86..5f7599a 100644 --- a/src/staminafilter.cc +++ b/src/staminafilter.cc @@ -41,31 +41,26 @@ bool StaminaFilter::filter(event_t& event, size_t pos) auto enable_velocity_modifier = settings.enable_velocity_modifier.load(); auto velocity_modifier_weight = settings.velocity_modifier_weight.load(); + auto& pair = modifiers[event.instrument]; + if(modifiers.find(event.instrument) == modifiers.end()) { // On first lookup make sure we have sane values. - auto& pair = modifiers[event.instrument]; pair.first = 1.0f; pair.second = 0; } - - auto& pair = modifiers[event.instrument]; auto& mod = pair.first; auto& lastpos = pair.second; - if(enable_velocity_modifier == false) - { - mod = 1.0f; - lastpos = 0; - } - if(enable_velocity_modifier) { mod += (pos - lastpos) / (samplerate * velocity_modifier_falloff); - if(mod > 1.0f) - { - mod = 1.0f; - } + mod = std::min(mod, 1.0f); + } + else + { + mod = 1.0f; + lastpos = 0; } event.velocity *= mod; |