Etterna 0.74.4
Loading...
Searching...
No Matches
WideRangeBalance.h
1#pragma once
2#include "../IntervalHandInfo.h"
3
7{
8 const CalcPatternMod _pmod = WideRangeBalance;
9 const std::string name = "WideRangeBalanceMod";
10
11#pragma region params
12
13 float window_param = 2.F;
14
15 float min_mod = 0.94F;
16 float max_mod = 1.05F;
17 float base = 0.425F;
18
19 float buffer = 1.F;
20 float scaler = 1.F;
21 float other_scaler = 4.F;
22
23 const std::vector<std::pair<std::string, float*>> _params{
24 { "window_param", &window_param },
25
26 { "min_mod", &min_mod },
27 { "max_mod", &max_mod },
28 { "base", &base },
29
30 { "buffer", &buffer },
31 { "scaler", &scaler },
32 { "other_scaler", &other_scaler },
33 };
34#pragma endregion params and param map
35
36 int window = 0;
37 float pmod = neutral;
38
39 void full_reset() { pmod = neutral; }
40
41 void setup()
42 {
43 // setup should be run after loading params from disk
44 window =
45 std::clamp(static_cast<int>(window_param), 1, max_moving_window_size);
46 }
47
48 auto operator()(const ItvHandInfo& itvhi) -> float
49 {
50 // nothing here
51 if (itvhi.get_taps_nowi() == 0) {
52 return neutral;
53 }
54
55 // same number of taps on each column for this window
56 if (itvhi.cols_equal_window(window)) {
57 return min_mod;
58 }
59
60 pmod = itvhi.get_col_prop_low_by_high_window(window);
61
62 pmod = (base + (buffer + (scaler / pmod)) / other_scaler);
63 pmod = std::clamp(pmod, min_mod, max_mod);
64
65 return pmod;
66 }
67};
accumulates hand specific info across an interval as it's processed by row
Definition IntervalHandInfo.h:6
auto get_taps_nowi() const -> int
access functions for hand tap counts
Definition IntervalHandInfo.h:135
Definition WideRangeBalance.h:7