summaryrefslogtreecommitdiff
path: root/src/inputprocessor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/inputprocessor.cc')
-rw-r--r--src/inputprocessor.cc51
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)
{