|
12 | 12 | constexpr float min_threshold = 0.65F;
|
13 | 13 | static const float downscale_logbase = std::log(6.2F);
|
14 | 14 |
|
| 15 | +constexpr float scaler_for_ms_base = 1.175F; |
| 16 | +// i do not know a proper name for these |
| 17 | +constexpr float ms_base_finger_weighter_2 = 9.F; |
| 18 | +constexpr float ms_base_finger_weighter = 5.5F; |
| 19 | + |
| 20 | +static auto |
| 21 | +CalcMSEstimate(std::vector<float>& input, const int& burp) -> float |
| 22 | +{ |
| 23 | + // how many ms values we use from here, if there are fewer than this |
| 24 | + // number we'll mock up some values to water down intervals with a |
| 25 | + // single extremely fast minijack, if there are more, we will truncate |
| 26 | + unsigned int num_used = burp; |
| 27 | + |
| 28 | + if (input.empty()) { |
| 29 | + return 0.F; |
| 30 | + } |
| 31 | + |
| 32 | + // avoiding this for now because of smoothing |
| 33 | + // single ms value, dunno if we want to do this? technically the tail |
| 34 | + // end of an insanely hard burst that gets lopped off at the last note |
| 35 | + // is still hard? if (input.size() < 2) return 1.f; |
| 36 | + |
| 37 | + // sort before truncating/filling |
| 38 | + std::sort(input.begin(), input.end()); |
| 39 | + |
| 40 | + // truncate if we have more values than what we care to sample, we're |
| 41 | + // looking for a good estimate of the hardest part of this interval |
| 42 | + // if above 1 and below used_ms_vals, fill up the stuff with dummies |
| 43 | + // my god i was literally an idiot for doing what i was doing before |
| 44 | + static const float ms_dummy = 360.F; |
| 45 | + |
| 46 | + // mostly try to push down stuff like jumpjacks, not necessarily to push |
| 47 | + // up "complex" stuff (this will push up intervals with few fast ms |
| 48 | + // values kinda hard but it shouldn't matter as their base ms diff |
| 49 | + // should be extremely low |
| 50 | + float cv_yo = cv_trunc_fill(input, burp, ms_dummy) + 0.5F; |
| 51 | + cv_yo = std::clamp(cv_yo, 0.5F, 1.25F); |
| 52 | + |
| 53 | + // basically doing a jank average, bigger m = lower difficulty |
| 54 | + float m = sum_trunc_fill(input, burp, ms_dummy); |
| 55 | + |
| 56 | + // add 1 to num_used because some meme about sampling |
| 57 | + // same thing as jack stuff, convert to bpm and then nps |
| 58 | + float bpm_est = ms_to_bpm(m / (num_used + 1)); |
| 59 | + float nps_est = bpm_est / 15.F; |
| 60 | + float fdiff = nps_est * cv_yo; |
| 61 | + return fdiff; |
| 62 | +} |
| 63 | + |
15 | 64 | struct nps
|
16 | 65 | {
|
17 |
| - /// determine NPSBase, itv_points for this hand |
| 66 | + /// determine NPSBase, itv_points, CJBase for this hand |
18 | 67 | static void actual_cancer(Calc& calc, const int& hand)
|
19 | 68 | {
|
20 |
| - for (auto itv = 0; itv < calc.numitv; ++itv) { |
| 69 | + // finger row times |
| 70 | + auto last_left_row_time = s_init; |
| 71 | + auto last_right_row_time = s_init; |
| 72 | + |
| 73 | + auto scaly_ms_estimate = [](std::vector<float>& input, |
| 74 | + const float& scaler) { |
| 75 | + float o = CalcMSEstimate(input, 3); |
| 76 | + if (input.size() > 3) { |
| 77 | + o = std::max(o, CalcMSEstimate(input, 4) * scaler); |
| 78 | + } |
| 79 | + if (input.size() > 4) { |
| 80 | + o = std::max(o, CalcMSEstimate(input, 5) * scaler * scaler); |
| 81 | + } |
| 82 | + return o; |
| 83 | + }; |
21 | 84 |
|
| 85 | + for (auto itv = 0; itv < calc.numitv; ++itv) { |
22 | 86 | auto notes = 0;
|
23 | 87 |
|
| 88 | + // times between rows for this interval for each finger |
| 89 | + std::vector<float> left_finger_ms{}; |
| 90 | + std::vector<float> right_finger_ms{}; |
| 91 | + |
24 | 92 | for (auto row = 0; row < calc.itv_size.at(itv); ++row) {
|
25 | 93 | const auto& cur = calc.adj_ni.at(itv).at(row);
|
26 | 94 | notes += cur.hand_counts.at(hand);
|
| 95 | + |
| 96 | + const auto& crt = cur.row_time; |
| 97 | + switch (determine_col_type(cur.row_notes, hand_col_ids[hand])) { |
| 98 | + case col_left: |
| 99 | + if (last_left_row_time != s_init) { |
| 100 | + const auto left_ms = |
| 101 | + ms_from(crt, last_left_row_time); |
| 102 | + left_finger_ms.push_back(left_ms); |
| 103 | + } |
| 104 | + last_left_row_time = crt; |
| 105 | + break; |
| 106 | + case col_right: |
| 107 | + if (last_right_row_time != s_init) { |
| 108 | + const auto right_ms = |
| 109 | + ms_from(crt, last_right_row_time); |
| 110 | + right_finger_ms.push_back(right_ms); |
| 111 | + } |
| 112 | + last_right_row_time = crt; |
| 113 | + break; |
| 114 | + case col_ohjump: |
| 115 | + if (last_right_row_time != s_init) { |
| 116 | + const auto right_ms = |
| 117 | + ms_from(crt, last_right_row_time); |
| 118 | + right_finger_ms.push_back(right_ms); |
| 119 | + } |
| 120 | + if (last_left_row_time != s_init) { |
| 121 | + const auto left_ms = |
| 122 | + ms_from(crt, last_left_row_time); |
| 123 | + left_finger_ms.push_back(left_ms); |
| 124 | + } |
| 125 | + last_left_row_time = crt; |
| 126 | + last_right_row_time = crt; |
| 127 | + break; |
| 128 | + case col_empty: |
| 129 | + case col_init: |
| 130 | + default: |
| 131 | + // none |
| 132 | + break; |
| 133 | + } |
27 | 134 | }
|
28 | 135 |
|
29 | 136 | // nps for this interval
|
30 |
| - calc.init_base_diff_vals.at(hand).at(NPSBase).at(itv) = |
31 |
| - static_cast<float>(notes) * finalscaler * 1.6F; |
| 137 | + const auto nps = static_cast<float>(notes) * finalscaler * 1.6F; |
| 138 | + calc.init_base_diff_vals.at(hand).at(NPSBase).at(itv) = nps; |
| 139 | + |
| 140 | + // ms base for this interval |
| 141 | + const auto left = |
| 142 | + scaly_ms_estimate(left_finger_ms, scaler_for_ms_base); |
| 143 | + const auto right = |
| 144 | + scaly_ms_estimate(right_finger_ms, scaler_for_ms_base); |
| 145 | + float msdiff = 0.F; |
| 146 | + if (left > right) { |
| 147 | + msdiff = weighted_average(left, |
| 148 | + right, |
| 149 | + ms_base_finger_weighter, |
| 150 | + ms_base_finger_weighter_2); |
| 151 | + } else { |
| 152 | + msdiff = weighted_average(right, |
| 153 | + left, |
| 154 | + ms_base_finger_weighter, |
| 155 | + ms_base_finger_weighter_2); |
| 156 | + } |
| 157 | + const auto msbase = finalscaler * msdiff; |
| 158 | + calc.init_base_diff_vals.at(hand).at(MSBase).at(itv) = msbase; |
| 159 | + ///// |
32 | 160 |
|
33 | 161 | // set points for this interval
|
34 | 162 | calc.itv_points.at(hand).at(itv) = notes * 2;
|
|
0 commit comments