Etterna 0.74.4
Loading...
Searching...
No Matches
HD_BasicSequencing.h
1#pragma once
2#include <cassert>
3
4/* everything needed for basic sequencing for hand dependent patterns, this file
5 * is dependent on nothing else and only operates on unsigned ints, and things
6 * it definess */
7
8// note: this are clearly restricted to 4k
9
10// refrence notemap
11// "----", "1---", "-1--", "11--",
12// "--1-", "1-1-", "-11-", "111-",
13// "---1", "1--1", "-1-1", "11-1",
14// "--11", "1-11", "-111", "1111" };
15
19enum col_type
20{
21 col_left,
22 col_right,
23 col_ohjump,
24 num_col_types,
25 col_empty,
26 col_init
27};
28
29static const int num_cols_per_hand = 2;
30static const std::array<col_type, num_col_types> ct_loop = { col_left,
31 col_right,
32 col_ohjump };
33static const std::array<col_type, num_cols_per_hand> ct_loop_no_jumps = {
34 col_left,
35 col_right
36};
37
39static inline auto
40determine_col_type(const unsigned& notes, const unsigned& hand_id) -> col_type
41{
42 const unsigned shirt = notes & hand_id;
43 if (shirt == 0) {
44 return col_empty;
45 }
46
47 if (hand_id == 3) {
48 if (shirt == 3) {
49 return col_ohjump;
50 }
51 if (shirt == 1) {
52 return col_left;
53 }
54 if (shirt == 2) {
55 return col_right;
56 }
57 } else if (hand_id == 12) {
58 if (shirt == 12) {
59 return col_ohjump;
60 }
61 if (shirt == 8) {
62 return col_right;
63 }
64 if (shirt == 4) {
65 return col_left;
66 }
67 }
68 assert(0);
69 return col_init;
70}
71
74inline auto
75invert_col(const col_type& col) -> col_type
76{
77 assert(col == col_left || col == col_right);
78 return col == col_left ? col_right : col_left;
79}
80
86enum base_type
87{
88 base_left_right,
89 base_right_left,
90 base_jump_single,
91 base_single_single,
92 base_single_jump,
93 base_jump_jump,
94 num_base_types,
95 base_type_init,
96};
97
99inline auto
100determine_base_pattern_type(const col_type& now, const col_type& last)
101 -> base_type
102{
103 if (last == col_init) {
104 return base_type_init;
105 }
106
107 const bool single_tap = now == col_left || now == col_right;
108 if (last == col_ohjump) {
109 if (single_tap) {
110 return base_jump_single;
111 }
112 { // can't be anything else
113 return base_jump_jump;
114 }
115 } else if (!single_tap) {
116 return base_single_jump;
117 // if we are on left col _now_, we are right to left
118 } else if (now == col_left && last == col_right) {
119 return base_right_left;
120 } else if (now == col_right && last == col_left) {
121 return base_left_right;
122 } else if (now == last) {
123 // anchor/jack
124 return base_single_single;
125 }
126
127 // makes no logical sense
128 assert(0);
129 return base_type_init;
130}
131
135inline auto
136is_cc_tap(const base_type& bt) -> bool
137{
138 return bt == base_left_right || bt == base_right_left;
139}