Etterna 0.75.1
Loading...
Searching...
No Matches
CJOHJ.h
1#pragma once
2#include "../IntervalHandInfo.h"
3#include "../HD_Sequencers/OHJSequencing.h"
4
10{
11 const CalcPatternMod _pmod = CJOHJump;
12 const std::string name = "CJOHJumpMod";
13
14#pragma region params
15
16 float min_mod = 0.57F;
17 float max_mod = 1.F;
18
19 float prop_pool = 1.F;
20 float prop_scaler = 0.63F;
21
22 const std::vector<std::pair<std::string, float*>> _params{
23 { "min_mod", &min_mod },
24 { "max_mod", &max_mod },
25
26 { "prop_pool", &prop_pool },
27 { "prop_scaler", &prop_scaler },
28 };
29#pragma endregion params and param map
30
31 OHJ_Sequencer ohj;
32 int max_ohjump_seq_taps = 0;
33
34 // number of jumps scaled to total taps in hand
35 float base_seq_prop = 0.F;
36 // size of sequence scaled to total taps in hand
37 float base_jump_prop = 0.F;
38
39 float prop_component = neutral;
40 float pmod = neutral;
41
42#pragma region generic functions
43
44 void full_reset()
45 {
46 ohj.zero();
47
48 max_ohjump_seq_taps = 0;
49
50 base_seq_prop = 0.F;
51 base_jump_prop = 0.F;
52
53 prop_component = neutral;
54 pmod = neutral;
55 }
56
57#pragma endregion
58
59 void advance_sequencing(const col_type& ct, const base_type& bt)
60 {
61 ohj(ct, bt);
62 }
63
64 // build component based on number of jumps relative to hand taps
65 void set_prop_comp()
66 {
67 prop_component = prop_pool - (base_jump_prop * prop_scaler);
68 prop_component = prop_component < 0.1F ? 0.1F : prop_component;
69 }
70
71 void set_pmod(const metaItvHandInfo& mitvhi)
72 {
73 const auto& itvhi = mitvhi._itvhi;
74
75 // if cur_seq > max when we ended the interval, grab it
76 max_ohjump_seq_taps = ohj.cur_seq_taps > ohj.max_seq_taps
77 ? ohj.cur_seq_taps
78 : ohj.max_seq_taps;
79
80 /* case optimization start */
81
82 // nothing here or there are no ohjumps
83 if (itvhi.get_taps_nowi() == 0 ||
84 itvhi.get_col_taps_nowi(col_ohjump) == 0) {
85 pmod = neutral;
86 return;
87 }
88
89 // everything in the interval is in an ohj sequence
90 if (max_ohjump_seq_taps >= itvhi.get_taps_nowi()) {
91 pmod = min_mod;
92 return;
93 }
94
95 // floats for less casting
96 // these should always be whole numbers
97 const auto ohjcount = itvhi.get_col_taps_nowf(col_ohjump) / 2.f;
98 const auto tapcount = (itvhi.get_col_taps_nowf(col_left) - ohjcount) +
99 (itvhi.get_col_taps_nowf(col_right) - ohjcount);
100 const auto rows = ohjcount + tapcount;
101
102 base_jump_prop = ohjcount / rows;
103 set_prop_comp();
104 prop_component = std::clamp(prop_component, 0.1F, max_mod);
105
106 pmod = prop_component;
107 pmod = std::clamp(pmod, min_mod, max_mod);
108 }
109
110 auto operator()(const metaItvHandInfo& mitvhi) -> float
111 {
112 set_pmod(mitvhi);
113
114 interval_end();
115 return pmod;
116 }
117
118 void interval_end()
119 {
120 // reset any interval stuff here
121 ohj.max_seq_taps = 0;
122 max_ohjump_seq_taps = 0;
123 }
124};
Definition CJOHJ.h:10
Definition OHJSequencing.h:8
this may prove to be overkill
Definition MetaIntervalHandInfo.h:6