Etterna 0.74.4
Loading...
Searching...
No Matches
VOHT.h
1#pragma once
2#include "../IntervalHandInfo.h"
3
4/* retuned oht mod focus tuned to for catching vibro trills like bagatelle */
5
6static const int max_vtrills_per_interval = 4;
7
13{
14 const CalcPatternMod _pmod = VOHTrill;
15 const std::string name = "VOHTrillMod";
16
17#pragma region params
18
19 float window_param = 2.F;
20
21 float min_mod = 0.25F;
22 float max_mod = 1.F;
23 float base = 1.5F;
24 float suppression = 0.2F;
25
26 float cv_reset = 1.F;
27 float cv_threshhold = 0.25F;
28
29 float min_len = 8.F;
30
31 const std::vector<std::pair<std::string, float*>> _params{
32 { "window_param", &window_param },
33
34 { "min_mod", &min_mod },
35 { "max_mod", &max_mod },
36 { "base", &base },
37 { "suppression", &suppression },
38
39 { "cv_reset", &cv_reset },
40 { "cv_threshhold", &cv_threshhold },
41
42 { "min_len", &min_len },
43 };
44#pragma endregion params and param map
45
46 int window = 0;
47 int cc_window = 0;
48
49 bool luca_turilli = false;
50
52 CalcMovingWindow<int> _mw_oht_taps;
53
54 std::array<int, max_vtrills_per_interval> foundyatrills = { 0, 0, 0, 0 };
55
56 int found_oht = 0;
57 int oht_len = 0;
58 int oht_taps = 0;
59
60 float hello_my_name_is_goat = 0.F;
61
62 float moving_cv = cv_reset;
63 float pmod = min_mod;
64
65#pragma region generic functions
66
67 void full_reset()
68 {
69 badjuju.zero();
70
71 luca_turilli = false;
72 found_oht = 0;
73 oht_len = 0;
74
75 for (auto& v : foundyatrills) {
76 v = 0;
77 }
78
79 moving_cv = cv_reset;
80 pmod = neutral;
81 }
82
83 void setup()
84 {
85 window =
86 std::clamp(static_cast<int>(window_param), 1, max_moving_window_size);
87 cc_window =
88 std::clamp(static_cast<int>(window_param), 1, max_moving_window_size);
89 }
90
91#pragma endregion
92
93 auto make_thing(const float& itv_taps) -> float
94 {
95 hello_my_name_is_goat = 0.F;
96
97 if (found_oht == 0) {
98 return 0.F;
99 }
100
101 for (auto& v : foundyatrills) {
102 if (v == 0) {
103 continue;
104 }
105
106 // water down smaller sequences
107 hello_my_name_is_goat =
108 (static_cast<float>(v) / itv_taps) - suppression;
109 }
110 return std::clamp(hello_my_name_is_goat, 0.1F, 1.F);
111 }
112
113 void complete_seq()
114 {
115 if (!luca_turilli || oht_len == 0) {
116 return;
117 }
118
119 if (found_oht < max_vtrills_per_interval) {
120 foundyatrills.at(found_oht) = oht_len;
121 }
122
123 luca_turilli = false;
124 oht_len = 0;
125 ++found_oht;
126 moving_cv = (moving_cv + cv_reset) / 2.F;
127 }
128
129 auto oht_timing_check(const CalcMovingWindow<float>& ms_any) -> bool
130 {
131 moving_cv = (moving_cv + ms_any.get_cv_of_window(cc_window)) / 2.F;
132 return moving_cv < cv_threshhold;
133 }
134
135 void wifflewaffle()
136 {
137 if (luca_turilli) {
138 ++oht_len;
139 ++oht_taps;
140 } else {
141 luca_turilli = true;
142 oht_len += 3;
143 oht_taps += 3;
144 }
145 }
146
147 void advance_sequencing(const meta_type& mt,
148 const CalcMovingWindow<float>& ms_any)
149 {
150
151 switch (mt) {
152 case meta_cccccc:
153 if (oht_timing_check(ms_any)) {
154 wifflewaffle();
155 } else {
156 complete_seq();
157 }
158 break;
159 case meta_ccacc:
160 // wait to see what happens
161 break;
162 case meta_enigma:
163 case meta_meta_enigma:
164 default:
165 complete_seq();
166 break;
167 }
168 }
169
170 void set_pmod(const ItvHandInfo& itvhi)
171 {
172
173 // no taps, no trills
174 if (itvhi.get_taps_windowi(window) == 0 ||
175 _mw_oht_taps.get_total_for_window(window) == 0) {
176 pmod = neutral;
177 return;
178 }
179
180 if (_mw_oht_taps.get_total_for_window(window) < min_len) {
181 pmod = neutral;
182 return;
183 }
184
185 // full oht
186 if (itvhi.get_taps_windowi(window) ==
187 _mw_oht_taps.get_total_for_window(window)) {
188 pmod = min_mod;
189 return;
190 }
191
192 badjuju(make_thing(itvhi.get_taps_nowf()));
193
194 pmod = base - badjuju.get_mean_of_window(window);
195 pmod = std::clamp(pmod, min_mod, max_mod);
196 }
197
198 auto operator()(const ItvHandInfo& itvhi) -> float
199 {
200 if (oht_len > 0 && found_oht < max_vtrills_per_interval) {
201 foundyatrills.at(found_oht) = oht_len;
202 ++found_oht;
203 }
204
205 _mw_oht_taps(oht_taps);
206
207 set_pmod(itvhi);
208
209 interval_end();
210 return pmod;
211 }
212
213 void interval_end()
214 {
215 foundyatrills.fill(0);
216 found_oht = 0;
217 oht_len = 0;
218 oht_taps = 0;
219 }
220};
Definition CalcWindow.h:15
void zero()
set everything to zero
Definition CalcWindow.h:210
auto get_total_for_window(const int &window) const -> T
get the sum for the moving window up to a given size
Definition CalcWindow.h:46
auto get_mean_of_window(const int &window) const -> float
get the mean for the moving window up to a given size
Definition CalcWindow.h:85
auto get_cv_of_window(const int &window) const -> float
get the coefficient of variance of the moving window up to a given size
Definition CalcWindow.h:113
accumulates hand specific info across an interval as it's processed by row
Definition IntervalHandInfo.h:6
auto get_taps_nowf() const -> float
cast to float for divisioning and clean screen
Definition IntervalHandInfo.h:141
Definition VOHT.h:13