Etterna 0.74.4
Loading...
Searching...
No Matches
ThingSequencing.h
1#pragma once
2#include <cassert>
3
4/* search for specific patterns that when chained together are extremely
5 * jumptrillable, currently detection is separated, but it should probably be
6 * combined */
7
15{
16 enum to_slide_or_not_to_slide
17 {
18 slip_unbeginninged,
19 needs_single,
20 needs_23_jump,
21 needs_opposing_single,
22 needs_opposing_ohjump,
23 slip_complete
24 };
25
27 unsigned slip = 0;
31 int slide = 0;
32
33 // ms values, 4 ms values = 5 rows, optimize by just recycling values
34 // without resetting and indexing up to the size counter to get duration
35 // float ms[4] = {
36 // 0.f,
37 // 0.f,
38 // 0.f,
39 // 0.f,
40 //};
41
42 // couldn't figure out how to make slip & slide work smh
43 [[nodiscard]] auto the_slip_is_the_boot(const unsigned& notes) const -> bool
44 {
45 switch (slide) {
46 // just started, need single note with no jack between our starting
47 // point and [23]
48 case needs_single:
49 // 1100 requires 0001
50 if (slip == 3 || slip == 7) {
51 if (notes == 8) {
52 return true;
53 }
54 } else
55 // if it's not a left hand jump, it's a right hand one, we
56 // need 1000
57 if (notes == 1) {
58 return true;
59 }
60 break;
61 case needs_23_jump:
62 // has to be [23]
63 if (notes == 6) {
64 return true;
65 }
66 break;
67 case needs_opposing_single:
68 // same as 1 but reversed
69
70 // 1100
71 // 0001
72 // 0110
73 // requires 1000
74 if (slip == 3 || slip == 7) {
75 if (notes == 1) {
76 return true;
77 }
78 } else
79 // if it's not a left hand jump, it's a right hand one, we
80 // need 0001
81 if (notes == 8) {
82 return true;
83 }
84 break;
85 case needs_opposing_ohjump:
86 if (slip == 3 || slip == 7) {
87 // if we started on 1100, we end on 0011
88 // make detecc more inclusive i guess by allowing 0100
89 if (notes == 12 || notes == 14) {
90 return true;
91 }
92 } else
93 // starting on 0011 ends on 1100
94 // make detecc more inclusive i guess by allowing 0010
95 if (notes == 3 || notes == 7) {
96 return true;
97 }
98 break;
99 default:
100 assert(0);
101 break;
102 }
103 return false;
104 }
105
106 void start(const float& ms_now, const unsigned& notes)
107 {
108 slip = notes;
109 slide = 0;
111 grow(ms_now, notes);
112 }
113
114 void grow(const float& /*ms_now*/, const unsigned& /*notes*/)
115 {
116 // ms[slide] = ms_now;
117 ++slide;
118 }
119
120 void reset() { slippin_till_ya_slips_come_true = false; }
121};
122
130{
131 enum to_slide_or_not_to_slide
132 {
133 slip_unbeginninged,
134 needs_single,
135 needs_door,
136 needs_blaap,
137 needs_opposing_ohjump,
138 slip_complete
139 };
140
142 unsigned slip = 0;
143 // are we slipping
144 bool slippin_till_ya_slips_come_true = false;
146 int slide = 0;
147
148 // ms values, 4 ms values = 5 rows, optimize by just recycling values
149 // without resetting and indexing up to the size counter to get duration
150 // float ms[4] = {
151 // 0.f,
152 // 0.f,
153 // 0.f,
154 // 0.f,
155 //};
156
157 // couldn't figure out how to make slip & slide work smh
158 [[nodiscard]] auto the_slip_is_the_boot(const unsigned& notes) const -> bool
159 {
160 switch (slide) {
161 // just started, need single note with no jack between our starting
162 // point and [23]
163 case needs_single:
164 // 1100 requires 0010
165 if (slip == 3) {
166 if (notes == 4) {
167 return true;
168 }
169 } else if (notes == 2) {
170 return true;
171 }
172 break;
173 case needs_door:
174 if (slip == 3) {
175 if (notes == 10) {
176 return true;
177 }
178 } else if (notes == 5) {
179 return true;
180 }
181 break;
182 case needs_blaap:
183 // it's alive
184
185 // requires 1000
186 if (slip == 3) {
187 if (notes == 1) {
188 return true;
189 }
190 } else if (notes == 8) {
191 return true;
192 }
193 break;
194 case needs_opposing_ohjump:
195 if (slip == 3) {
196 // if we started on 1100, we end on 0011
197 if (notes == 12) {
198 return true;
199 }
200 } else
201 // starting on 0011 ends on 1100
202 if (notes == 3) {
203 return true;
204 }
205 break;
206 default:
207 assert(0);
208 break;
209 }
210 return false;
211 }
212
213 void start(const float& ms_now, const unsigned& notes)
214 {
215 slip = notes;
216 slide = 0;
217 slippin_till_ya_slips_come_true = true;
218 grow(ms_now, notes);
219 }
220
221 void grow(const float& /*ms_now*/, const unsigned& /*notes*/)
222 {
223 // ms[slide] = ms_now;
224 ++slide;
225 }
226
227 void reset() { slippin_till_ya_slips_come_true = false; }
228};
229
230// sort of the same concept as fj, slightly different implementation
231// used by thing1
233{
234 the_slip fizz;
235 int slip_counter = 0;
236 static const int max_slips = 4;
237 std::array<float, max_slips> mod_parts = { 1.F, 1.F, 1.F, 1.F };
238
239 float scaler = 0.F;
240
241 void set_params(const float& /*gt*/, const float& /*st*/, const float& ms)
242 {
243 // group_tol = gt;
244 // step_tol = st;
245 scaler = ms;
246 }
247
248 void complete_slip(const float& ms_now, const unsigned& notes)
249 {
250 if (slip_counter < max_slips) {
251 mod_parts.at(slip_counter) = construct_mod_part();
252 }
253 ++slip_counter;
254
255 // any time we complete a slip we can start another slip, so just
256 // start again
257 fizz.start(ms_now, notes);
258 }
259
260 // only start if we pick up ohjump or hand with an ohjump, not a quad, not
261 // singles
262 static auto start_test(const unsigned& notes) -> bool
263 {
264 // either left hand jump or a hand containing left hand jump
265 // or right hand jump or a hand containing right hand jump
266
267 return notes == 3 || notes == 7 || notes == 12 || notes == 14;
268 }
269
270 void operator()(const float& ms_now, const unsigned& notes)
271 {
272 // ignore quads
273 if (notes == 15) {
274 // reset if we are in a sequence
276 fizz.reset();
277 }
278 return;
279 }
280
281 // haven't started
283 // col check to start
284 if (start_test(notes)) {
285 fizz.start(ms_now, notes);
286 }
287 return;
288 }
289 // run the col checks for continuation
290 if (fizz.the_slip_is_the_boot(notes)) {
291 fizz.grow(ms_now, notes);
292 // we found... the thing
293 if (fizz.slide == 5) {
294 complete_slip(ms_now, notes);
295 }
296 } else {
297 // reset if we fail col check
298 fizz.reset();
299 }
300 }
301
302 void reset()
303 {
304 slip_counter = 0;
305 mod_parts.fill(1.F);
306 }
307
308 [[nodiscard]] auto construct_mod_part() const -> float { return scaler; }
309};
310
311// sort of the same concept as fj, slightly different implementation
312// used by thing2
314{
315 the_slip2 fizz;
316 int slip_counter = 0;
317 static const int max_slips = 4;
318 std::array<float, max_slips> mod_parts = { 1.F, 1.F, 1.F, 1.F };
319
320 float scaler = 0.F;
321
322 void set_params(const float& /*gt*/, const float& /*st*/, const float& ms)
323 {
324 // group_tol = gt;
325 // step_tol = st;
326 scaler = ms;
327 }
328
329 void complete_slip(const float& ms_now, const unsigned& notes)
330 {
331 if (slip_counter < max_slips) {
332 mod_parts.at(slip_counter) = construct_mod_part();
333 }
334 ++slip_counter;
335
336 // any time we complete a slip we can start another slip, so just
337 // start again
338 fizz.start(ms_now, notes);
339 }
340
341 // only start if we pick up ohjump or hand with an ohjump, not a quad, not
342 // singles
343 static auto start_test(const unsigned& notes) -> bool
344 {
345 // either left hand jump or a hand containing left hand jump
346 // or right hand jump or a hand containing right hand jump
347 return notes == 3 || notes == 12;
348 }
349
350 void operator()(const float& ms_now, const unsigned& notes)
351 {
352 // ignore quads
353 if (notes == 15) {
354 // reset if we are in a sequence
355 if (fizz.slippin_till_ya_slips_come_true) {
356 fizz.reset();
357 }
358 return;
359 }
360
361 // haven't started
362 if (!fizz.slippin_till_ya_slips_come_true) {
363 // col check to start
364 if (start_test(notes)) {
365 fizz.start(ms_now, notes);
366 }
367 return;
368 }
369 // run the col checks for continuation
370 if (fizz.the_slip_is_the_boot(notes)) {
371 fizz.grow(ms_now, notes);
372 // we found... the thing
373 if (fizz.slide == 5) {
374 complete_slip(ms_now, notes);
375 }
376 } else {
377 // reset if we fail col check
378 fizz.reset();
379 }
380 }
381
382 void reset()
383 {
384 slip_counter = 0;
385 mod_parts.fill(1.F);
386 }
387
388 [[nodiscard]] auto construct_mod_part() const -> float { return scaler; }
389};
Definition ThingSequencing.h:314
Definition ThingSequencing.h:233
Definition ThingSequencing.h:130
unsigned slip
what caused us to slip
Definition ThingSequencing.h:142
int slide
how far those whomst'd've been slippinging
Definition ThingSequencing.h:146
Definition ThingSequencing.h:15
bool slippin_till_ya_slips_come_true
are we slipping
Definition ThingSequencing.h:29
int slide
how far those whomst'd've been slippinging
Definition ThingSequencing.h:31
unsigned slip
what caused us to slip
Definition ThingSequencing.h:27