Etterna 0.75.1
Loading...
Searching...
No Matches
OldRollScaler.h
1#pragma once
2#include "../MetaIntervalHandInfo.h"
3
6{
7 const CalcPatternMod _pmod = OldRollScaler;
8 const std::string name = "OldRollScalerMod";
9
10#pragma region params
11
12 float min_mod = 0.9F;
13 float max_mod = 1.075F;
14
15 float use_cv_threshold = 0.6F;
16 float min_cv = 0.15F;
17 float cv_base = 0.85F;
18 float power_scale = 6.F;
19
20 const std::vector<std::pair<std::string, float*>> _params{
21 { "min_mod", &min_mod },
22 { "max_mod", &max_mod },
23
24 { "use_cv_threshold", &use_cv_threshold },
25 { "min_cv", &min_cv },
26 { "cv_base", &cv_base },
27 { "power_scale", &power_scale },
28 };
29#pragma endregion params and param map
30
31 float pmod = neutral;
32
33 std::vector<float> all_ms{};
34 bool left_empty = true;
35 bool right_empty = true;
36
37#pragma region generic functions
38
39 void full_reset() {
40 pmod = neutral;
41 interval_end();
42 }
43
44 void interval_end() {
45 all_ms.clear();
46 left_empty = true;
47 right_empty = true;
48 }
49
50#pragma endregion
51
52 void advance_sequencing(const col_type& ct, const float& any_ms) {
53 switch (ct) {
54 case col_left:
55 left_empty = false;
56 all_ms.push_back(any_ms);
57 break;
58 case col_right:
59 right_empty = false;
60 all_ms.push_back(any_ms);
61 break;
62 case col_ohjump:
63 all_ms.push_back(any_ms);
64 all_ms.push_back(any_ms);
65 left_empty = false;
66 right_empty = false;
67 break;
68 default:
69 break;
70 }
71 }
72
73 void set_pmod(const ItvHandInfo& itvhi)
74 {
75
76 if (left_empty || right_empty || all_ms.size() == 1) {
77 pmod = neutral;
78 } else {
79
80 const auto mmm = mean(all_ms);
81
82 for (auto& x : all_ms) {
83 x = mmm / x < use_cv_threshold ? mmm : x;
84 }
85
86 const auto dacv = cv(all_ms);
87 if (dacv >= min_cv) {
88 pmod = fastsqrt(fastsqrt(cv_base + dacv));
89 } else {
90 pmod = fastpow(cv_base + dacv, power_scale);
91 }
92 }
93 pmod = std::clamp(pmod, min_mod, max_mod);
94 }
95
96 auto operator()(const ItvHandInfo& itvhi) -> float
97 {
98 set_pmod(itvhi);
99
100 // lazy. reset this pmod when we query it
101 interval_end();
102 return pmod;
103 }
104};
accumulates hand specific info across an interval as it's processed by row
Definition IntervalHandInfo.h:6
Hand downscaler based on how trilly the hand is.
Definition OldRollScaler.h:6