11constexpr float s_init = -5.F;
13constexpr float ms_init = 5000.F;
16constexpr float finalscaler = 3.632F * 1.06F;
19static const bool ignore_middle_column =
true;
23keycount_to_bin(
const unsigned& keycount) ->
unsigned
27 return ~(~1u << (keycount - 1u));
32right_mask(
const unsigned& keycount) ->
unsigned
36 return keycount_to_bin(keycount) >> (keycount / 2) << (keycount / 2);
41left_mask(
const unsigned& keycount) ->
unsigned
43 const auto m = right_mask(keycount);
44 return ~m &
static_cast<int>(std::exp2(std::ceil(std::log2(m))) - 1);
49mask_to_remove_middle_column(
const unsigned& keycount) ->
unsigned
51 if (keycount % 2 == 0) {
52 return keycount_to_bin(keycount);
54 return keycount_to_bin(keycount) ^ (0b1 << (keycount / 2));
59column_count(
const unsigned& notes) ->
int
61 return std::popcount(notes);
65is_only_1_bit(
const unsigned& notes) ->
bool
67 return notes && !(notes & (notes - 1));
73find_non_empty_cols(
const unsigned& notes) -> std::vector<unsigned>
75 std::vector<unsigned> o{};
76 for (
auto i = 0u; 1u << i <= notes; i++) {
77 if (((1u << i) & notes) != 0u) {
86ms_from(
const float& now,
const float& last) ->
float
88 return (now - last) * 1000.F;
93ms_to_bpm(
const float& x) ->
float
100ms_to_nps(
const float& x) ->
float
108ms_to_scaled_nps(
const float& ms) ->
float
110 return ms_to_nps(ms) * finalscaler;
114max_val(
const std::vector<int>& v) ->
int
116 return *std::max_element(v.begin(), v.end());
120max_val(
const std::vector<float>& v) ->
float
122 return *std::max_element(v.begin(), v.end());
126max_index(
const std::vector<float>& v) ->
int
128 return static_cast<int>(
129 std::distance(v.begin(), std::max_element(v.begin(), v.end())));
144constexpr float any_ms_epsilon = 0.1F;
148any_ms_is_greater(
float a,
float b) ->
bool
150 return (a - b) > any_ms_epsilon;
155any_ms_is_lesser(
float a,
float b) ->
bool
157 return (b - a) > any_ms_epsilon;
162any_ms_is_close(
float a,
float b) ->
bool
164 return fabsf(a - b) <= any_ms_epsilon;
169any_ms_is_zero(
float a) ->
bool
171 return any_ms_is_close(a, 0.F);