Etterna 0.74.4
Loading...
Searching...
No Matches
WideRangeJumptrill.h
1#pragma once
2#include "../IntervalHandInfo.h"
3
4// big brain stuff
5constexpr float wrjt_cv_factor = 3.F;
6
13{
14 const CalcPatternMod _pmod = { WideRangeJumptrill };
15 const std::string name = "WideRangeJumptrillMod";
16
17#pragma region params
18
19 float window_param = 3.F;
20
21 float min_mod = 0.25F;
22 float max_mod = 1.F;
23
24 float cv_threshhold = 0.05F;
25
26 const std::vector<std::pair<std::string, float*>> _params{
27 { "window_param", &window_param },
28
29 { "min_mod", &min_mod },
30 { "max_mod", &max_mod },
31
32 { "cv_threshhold", &cv_threshhold },
33 };
34#pragma endregion params and param map
35
36 int window = 0;
38 int jt_counter = 0;
39
40 bool bro_is_this_file_for_real = false;
41 bool last_passed_check = false;
42
43 float pmod = neutral;
44
45 std::array<float, 3> seq_ms = { 0.F, 0.F, 0.F };
46
47 // put this back again? seems to work well for wrr, however wrr is already
48 // more generalized anyway
49 // float moving_cv = moving_cv_init;
50
51#pragma region generic functions
52
53 void full_reset()
54 {
55 _mw_jt.zero();
56 jt_counter = 0;
57 seq_ms.fill(0.F);
58
59 bro_is_this_file_for_real = false;
60 last_passed_check = false;
61 pmod = neutral;
62 }
63
64 void setup()
65 {
66 window =
67 std::clamp(static_cast<int>(window_param), 1, max_moving_window_size);
68 }
69
70#pragma endregion
71
72 [[nodiscard]] auto check_last_mt(const meta_type& mt) const -> bool
73 {
74 if (mt == meta_acca || mt == meta_ccacc || mt == meta_cccccc) {
75 if (last_passed_check) {
76 return true;
77 }
78 }
79 return false;
80 }
81
82 void bibblybop(const meta_type& mt)
83 {
84 ++jt_counter;
85 if (bro_is_this_file_for_real) {
86 ++jt_counter;
87 }
88 if (check_last_mt(mt)) {
89 ++jt_counter;
90 bro_is_this_file_for_real = true;
91 }
92 }
93
94 void advance_sequencing(const base_type& bt,
95 const meta_type& mt,
96 const meta_type& _last_mt,
98 {
99 // ignore if we hit a jump
100 if (bt == base_jump_jump || bt == base_single_jump) {
101 return;
102 }
103
104 // note to self, im pretty sure we can use tc_ms to do half these checks
105 // more reliably and faster, and without dropping the const
106 // qualification, but i need to think about it
107
108 // look for stuff thats jumptrillyable.. if that stuff... then leads
109 // into more stuff.. that is jumptrillyable... then .... badonk it
110 switch (mt) {
111 case meta_cccccc:
112 if ((last_passed_check = ms_any.roll_timing_check(
113 wrjt_cv_factor, cv_threshhold))) {
114 bibblybop(_last_mt);
115 return;
116 }
117 break;
118 case meta_ccacc:
119 if ((last_passed_check = ms_any.ccacc_timing_check(
120 wrjt_cv_factor, cv_threshhold))) {
121 bibblybop(_last_mt);
122 return;
123 }
124 break;
125 case meta_acca:
126 // don't bother adding if the ms values look benign
127 if ((last_passed_check = ms_any.acca_timing_check(
128 wrjt_cv_factor, cv_threshhold))) {
129 bibblybop(_last_mt);
130 return;
131 }
132 break;
133 default:
134 break;
135 }
136
137 bro_is_this_file_for_real = false;
138 }
139
140 void set_pmod(const ItvHandInfo& itvhi)
141 {
142 // no taps, no jt
143 if (itvhi.get_taps_windowi(window) == 0 ||
144 _mw_jt.get_total_for_window(window) == 0) {
145 pmod = neutral;
146 return;
147 }
148
149 if (_mw_jt.get_total_for_window(window) < 20) {
150 pmod = neutral;
151 return;
152 }
153
154 pmod = itvhi.get_taps_windowf(window) /
155 _mw_jt.get_total_for_windowf(window) * 0.75F;
156
157 pmod = std::clamp(pmod, min_mod, max_mod);
158 }
159
160 auto operator()(const ItvHandInfo& itvhi) -> float
161 {
162 _mw_jt(jt_counter);
163
164 set_pmod(itvhi);
165
166 interval_end();
167 return pmod;
168 }
169
170 void interval_end()
171 {
172 // we could count these in metanoteinfo but let's do it here for now,
173 // reset every interval when finished
174 jt_counter = 0;
175 }
176};
Definition CalcWindow.h:15
void zero()
set everything to zero
Definition CalcWindow.h:210
auto get_total_for_windowf(const int &window) const -> float
Definition CalcWindow.h:100
auto get_total_for_window(const int &window) const -> T
get the sum for the moving window up to a given size
Definition CalcWindow.h:46
auto roll_timing_check(const float &factor, const float &threshold) -> bool
perform cv check internally
Definition CalcWindow.h:187
auto ccacc_timing_check(const float &factor, const float &threshold) -> bool
perform cv check internally
Definition CalcWindow.h:155
auto acca_timing_check(const float &factor, const float &threshold) -> bool
perform cv check internally
Definition CalcWindow.h:176
accumulates hand specific info across an interval as it's processed by row
Definition IntervalHandInfo.h:6
auto get_taps_windowf(const int &window) const -> float
cast to float for divisioning and clean screen
Definition IntervalHandInfo.h:153
Definition WideRangeJumptrill.h:13