Etterna 0.74.4
Loading...
Searching...
No Matches
HA_Sequencing.h
1#pragma once
2/* hand agnostic pattern sequencing is a little less developed than its
3 * counterpart and just contains some basic bitwise helpers for the moment */
4
7
9inline auto
10is_single_tap(const unsigned& a) -> bool
11{
12 return (a & (a - 1)) == 0;
13}
14
17inline auto
18is_jack_at_col(const unsigned& columnId,
19 const unsigned& row_notes,
20 const unsigned& last_row_notes) -> bool
21{
22 return ((columnId & row_notes) != 0U) && ((columnId & last_row_notes) != 0U);
23}
24
28inline auto
29is_alternating_chord_single(const unsigned& a, const unsigned& b) -> bool
30{
31 return (a > 1 && b == 1) || (a == 1 && b > 1);
32}
33
36inline auto
37is_alternating_chord_stream(const unsigned& a,
38 const unsigned& b,
39 const unsigned& c) -> bool
40{
41 if (is_single_tap(a)) {
42 if (is_single_tap(b)) {
43 // single single, don't care, bail
44 return false;
45 }
46 if (!is_single_tap(c)) { // single, chord, chord, bail
47 return false;
48 }
49 } else {
50 if (!is_single_tap(b)) {
51 // chord chord, don't care, bail
52 return false;
53 }
54 if (is_single_tap(c)) { // chord, single, single, bail
55 return false;
56 }
57 }
58 // we have either 1[n]1 or [n]1[n], check for any jacks
59 return static_cast<int>(((a & b) != 0U) && ((b & c) != 0U)) == 0;
60}