Etterna 0.74.4
Loading...
Searching...
No Matches
IntervalHandInfo.h
1#pragma once
2#include "../CalcWindow.h"
3
6{
7 void set_col_taps(const col_type& col)
8 {
9 // this could be more efficient but at least it's clear (ish)?
10 switch (col) {
11 case col_left:
12 case col_right:
13 ++_col_taps.at(col);
14 break;
15 case col_ohjump:
16 ++_col_taps.at(col_left);
17 ++_col_taps.at(col_right);
18 _col_taps.at(col) += 2;
19 break;
20 default:
21 assert(0);
22 break;
23 }
24 }
25
28 {
29 // update interval mw for hand taps
30 _mw_hand_taps(_col_taps.at(col_left) + _col_taps.at(col_right));
31
32 // update interval mws for col taps
33 for (auto& ct : ct_loop) {
34 _mw_col_taps.at(ct)(_col_taps.at(ct));
35 }
36
37 // reset taps per col on this hand
38 _col_taps.fill(0);
39 }
40
43 void zero()
44 {
45 _col_taps.fill(0);
46
47 for (auto& mw : _mw_col_taps) {
48 mw.zero();
49 }
50 _mw_hand_taps.zero();
51 }
52
54 [[nodiscard]] auto get_col_taps_nowi(const col_type& ct) const -> int
55 {
56 assert(ct < num_col_types);
57 return _mw_col_taps.at(ct).get_now();
58 }
59
61 [[nodiscard]] auto get_col_taps_nowf(const col_type& ct) const -> float
62 {
63 assert(ct < num_col_types);
64 return static_cast<float>(_mw_col_taps.at(ct).get_now());
65 }
66
67 [[nodiscard]] auto get_col_taps_windowi(const col_type& ct,
68 const int& window) const -> int
69 {
70 assert(ct < num_col_types && window < max_moving_window_size);
71 return _mw_col_taps.at(ct).get_total_for_window(window);
72 }
73
75 [[nodiscard]] auto get_col_taps_windowf(const col_type& ct,
76 const int& window) const -> float
77 {
78 assert(ct < num_col_types && window < max_moving_window_size);
79 return static_cast<float>(
80 _mw_col_taps.at(ct).get_total_for_window(window));
81 }
82
84 [[nodiscard]] auto cols_equal_now() const -> bool
85 {
86 return get_col_taps_nowi(col_left) == get_col_taps_nowi(col_right);
87 }
88
89 [[nodiscard]] auto cols_equal_window(const int& window) const -> bool
90 {
91 return get_col_taps_windowi(col_left, window) ==
92 get_col_taps_windowi(col_right, window);
93 }
94
95 [[nodiscard]] auto get_col_prop_high_by_low() const -> float
96 {
97 return div_high_by_low(get_col_taps_nowf(col_left),
98 get_col_taps_nowf(col_right));
99 }
100
101 [[nodiscard]] auto get_col_prop_low_by_high() const -> float
102 {
103 return div_low_by_high(get_col_taps_nowf(col_left),
104 get_col_taps_nowf(col_right));
105 }
106
107 [[nodiscard]] auto get_col_prop_high_by_low_window(const int& window) const
108 -> float
109 {
110 return div_high_by_low(get_col_taps_windowf(col_left, window),
111 get_col_taps_windowf(col_right, window));
112 }
113
114 [[nodiscard]] auto get_col_prop_low_by_high_window(const int& window) const
115 -> float
116 {
117 return div_low_by_high(get_col_taps_windowf(col_left, window),
118 get_col_taps_windowf(col_right, window));
119 }
120
121 [[nodiscard]] auto get_col_diff_high_by_low() const -> int
122 {
123 return diff_high_by_low(get_col_taps_nowi(col_left),
124 get_col_taps_nowi(col_right));
125 }
126
127 [[nodiscard]] auto get_col_diff_high_by_low_window(const int& window) const
128 -> int
129 {
130 return diff_high_by_low(get_col_taps_windowi(col_left, window),
131 get_col_taps_windowi(col_right, window));
132 }
133
135 [[nodiscard]] auto get_taps_nowi() const -> int
136 {
137 return _mw_hand_taps.get_now();
138 }
139
141 [[nodiscard]] auto get_taps_nowf() const -> float
142 {
143 return static_cast<float>(_mw_hand_taps.get_now());
144 }
145
146 [[nodiscard]] auto get_taps_windowi(const int& window) const -> int
147 {
148 assert(window < max_moving_window_size);
149 return _mw_hand_taps.get_total_for_window(window);
150 }
151
153 [[nodiscard]] auto get_taps_windowf(const int& window) const -> float
154 {
155 assert(window < max_moving_window_size);
156 return static_cast<float>(_mw_hand_taps.get_total_for_window(window));
157 }
158
159 private:
160 std::array<int, num_col_types> _col_taps = { 0, 0, 0 };
161
166 std::array<CalcMovingWindow<int>, num_col_types> _mw_col_taps;
167 CalcMovingWindow<int> _mw_hand_taps;
168};
Definition CalcWindow.h:15
void zero()
set everything to zero
Definition CalcWindow.h:210
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 get_now() const -> T
get most recent value in moving window
Definition CalcWindow.h:38
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
auto get_col_taps_nowi(const col_type &ct) const -> int
access functions for col tap counts
Definition IntervalHandInfo.h:54
void zero()
Definition IntervalHandInfo.h:43
auto get_col_taps_windowf(const col_type &ct, const int &window) const -> float
cast to float for divisioning and clean screen
Definition IntervalHandInfo.h:75
auto get_taps_windowf(const int &window) const -> float
cast to float for divisioning and clean screen
Definition IntervalHandInfo.h:153
void interval_end()
handle end of interval behavior here
Definition IntervalHandInfo.h:27
auto get_col_taps_nowf(const col_type &ct) const -> float
cast to float for divisioning and clean screen
Definition IntervalHandInfo.h:61
auto cols_equal_now() const -> bool
col operations
Definition IntervalHandInfo.h:84
auto get_taps_nowf() const -> float
cast to float for divisioning and clean screen
Definition IntervalHandInfo.h:141