diff options
author | André Nusser <andre.nusser@googlemail.com> | 2020-05-02 12:56:48 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-05-02 12:56:48 +0200 |
commit | 1671ee67a4d868811b3d3b5652b991d383a13679 (patch) | |
tree | d8aad40438ed02ce76515b6bcf7296a8eb1141f0 /src/inputprocessor.cc | |
parent | cf790d239d4b5dfa772d5d1fdb112b8640a4a81a (diff) |
Add powermap filter to the input processor and make sure that velocity visualizer is not affected but it.
Diffstat (limited to 'src/inputprocessor.cc')
-rw-r--r-- | src/inputprocessor.cc | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/inputprocessor.cc b/src/inputprocessor.cc index 6249c5b..2da5dbc 100644 --- a/src/inputprocessor.cc +++ b/src/inputprocessor.cc @@ -32,12 +32,53 @@ #include "instrument.h" -#include "staminafilter.h" #include "latencyfilter.h" +#include "powermapfilter.h" +#include "staminafilter.h" #include "velocityfilter.h" #include "cpp11fix.h" +class VelocityStorer + : public InputFilter +{ +public: + VelocityStorer(float& original_velocity) + : original_velocity(original_velocity) + { + } + + bool filter(event_t& event, std::size_t pos) override + { + original_velocity = event.velocity; + return true; + } + +private: + float& original_velocity; +}; + +class Reporter + : public InputFilter +{ +public: + Reporter(Settings& settings, float& original_velocity) + : settings(settings) + , original_velocity(original_velocity) + { + } + + bool filter(event_t& event, std::size_t pos) override + { + settings.velocity_modifier_current.store(event.velocity / original_velocity); + return true; + } + +private: + Settings& settings; + float& original_velocity; +}; + InputProcessor::InputProcessor(Settings& settings, DrumKit& kit, EventsDS& events_ds, @@ -47,9 +88,12 @@ InputProcessor::InputProcessor(Settings& settings, , settings(settings) { // Build filter list + filters.emplace_back(std::make_unique<PowermapFilter>(settings)); + filters.emplace_back(std::make_unique<VelocityStorer>(original_velocity)); filters.emplace_back(std::make_unique<StaminaFilter>(settings)); filters.emplace_back(std::make_unique<LatencyFilter>(settings, random)); filters.emplace_back(std::make_unique<VelocityFilter>(settings, random)); + filters.emplace_back(std::make_unique<Reporter>(settings, original_velocity)); } bool InputProcessor::process(std::vector<event_t>& events, @@ -178,7 +222,7 @@ bool InputProcessor::processOnset(event_t& event, std::size_t pos, return false; } - auto const original_level = event.velocity; + original_velocity = event.velocity; for(auto& filter : filters) { // This line might change the 'event' variable @@ -208,9 +252,6 @@ bool InputProcessor::processOnset(event_t& event, std::size_t pos, return false; } - auto const selected_level = (sample->getPower() - power_min)/power_span; - settings.velocity_modifier_current.store(selected_level/original_level); - events_ds.startAddingNewGroup(instrument_id); for(Channel& ch: kit.channels) { |