Etterna 0.75.1
Loading...
Searching...
No Matches
WideRangeCJAnchor.h
1#pragma once
2#include "../IntervalHandInfo.h"
3#include "../HD_Sequencers/GenericSequencing.h"
4
9{
10 const CalcPatternMod _pmod = WideRangeCJAnchor;
11 const std::string name = "WideRangeCJAnchorMod";
12
13#pragma region params
14
15 float min_mod = 0.5F;
16 float max_mod = 1.F;
17
18 float len_3_weight = 0.01F;
19 float len_long_weight = -0.0034F;
20 float min_required_taps = 7.F;
21 float moving_window_intervals = 2.F;
22 float long_anchor_pow_base = 1.025F;
23
24 const std::vector<std::pair<std::string, float*>> _params{
25 { "min_mod", &min_mod },
26 { "max_mod", &max_mod },
27
28 { "len_3_weight", &len_3_weight },
29 { "len_long_weight", &len_long_weight },
30 { "long_anchor_pow_base", &long_anchor_pow_base },
31
32 { "min_required_taps", &min_required_taps },
33 { "moving_window_intervals", &moving_window_intervals },
34 };
35#pragma endregion params and param map
36
37
38 // set in setup
39 float pmod = min_mod;
40
41 void full_reset()
42 {
43 interval_end();
44 pmod = neutral;
45 }
46
47 void setup()
48 {
49
50 }
51
52 void set_pmod(const ItvHandInfo& itvhi, const AnchorSequencer& as)
53 {
54 // if the interval has basically no notes to care about
55 // just bias to neutral
56 // this should help really low density charts not get nerfed
57 if (itvhi.get_taps_nowf() < min_required_taps) {
58 pmod = fastsqrt(pmod);
59 return;
60 }
61
62 const auto left = as.get_max_for_window_and_col(
63 col_left, static_cast<int>(moving_window_intervals));
64 const auto right = as.get_max_for_window_and_col(
65 col_right, static_cast<int>(moving_window_intervals));
66
67 // we are interested in whether or not a finger is anchoring hard
68 // this is different from WideRangeAnchor (which is weighing the difference of fingers)
69
70 const auto anchorest_value = left > right ? left : right;
71
72 if (anchorest_value < 3) {
73 // too short to care. the interval is full of probably not actual anchors
74 pmod = fastsqrt(pmod);
75
76 } else if (anchorest_value == 3) {
77 // 3 has one way to scale the pmod
78 pmod = fastsqrt(pmod) + len_3_weight;
79
80 } else {
81 // more than 3 has something more involved
82 // this generally means the longer the anchor the less it is worth
83 // if the weight is negative
84 pmod = pmod + fastpow(long_anchor_pow_base, anchorest_value) * len_long_weight;
85 }
86 }
87
88 auto operator()(const ItvHandInfo& itvhi, const AnchorSequencer& as)
89 -> float
90 {
91 set_pmod(itvhi, as);
92 pmod = std::clamp(pmod, min_mod, max_mod);
93
94 interval_end();
95 return pmod;
96 }
97
98 void interval_end()
99 {
100
101 }
102};
Definition GenericSequencing.h:308
accumulates hand specific info across an interval as it's processed by row
Definition IntervalHandInfo.h:6
auto get_taps_nowf() const -> float
cast to float for divisioning and clean screen
Definition IntervalHandInfo.h:141
Definition WideRangeCJAnchor.h:9