rt300@8
|
1 //
|
rt300@14
|
2 // SequenceGenerator.mm
|
rt300@8
|
3 // riftathon
|
rt300@8
|
4 //
|
rt300@14
|
5 // Created by Robert Tubb on 21/10/2014.
|
rt300@8
|
6 //
|
rt300@8
|
7 //
|
rt300@8
|
8
|
rt300@8
|
9 #include "SequenceController.h"
|
rt300@27
|
10 AnimStep::AnimStep(){
|
rt300@27
|
11 type = PREVIEW_NEUTRAL_COUNT;
|
rt300@27
|
12 presetIndex = -1;
|
rt300@27
|
13 seqNumber = -1;
|
rt300@43
|
14 runNumber = 0;
|
rt300@27
|
15 whichInSequence = -1;
|
rt300@27
|
16
|
rt300@27
|
17 tempo = MIN_TEMPO;
|
rt300@27
|
18
|
rt300@27
|
19 isLastOfSeq = false;
|
rt300@27
|
20 isLastOfRun = false;
|
rt300@27
|
21 isLastOfAll = false;
|
rt300@27
|
22
|
rt300@27
|
23 showsGuides = false;
|
rt300@31
|
24 showsIcons = true;
|
rt300@31
|
25 showsResultsAtEnd = false;
|
rt300@35
|
26 difficulty = 0;
|
rt300@36
|
27 setTimeFromTempo();
|
rt300@43
|
28 totalLengthOfSeq = 0;
|
rt300@27
|
29 }
|
rt300@31
|
30
|
rt300@31
|
31 void AnimStep::saveResult(TrainingTestResult aresult){
|
rt300@31
|
32 result = aresult;
|
rt300@31
|
33 }
|
rt300@31
|
34
|
rt300@21
|
35 Step::Step(){
|
rt300@21
|
36 type = COUNT_IN;
|
rt300@21
|
37
|
rt300@21
|
38 showsTargetIcon = false;
|
rt300@21
|
39 showsControlSettings = false;
|
rt300@21
|
40 showsControlGuides = false;
|
rt300@21
|
41 showsMatchResults = false;
|
rt300@22
|
42 hidesSliders = true;
|
rt300@21
|
43 isPreview = false;
|
rt300@21
|
44
|
rt300@21
|
45 allowsCandidateControl = false;
|
rt300@21
|
46 playsTarget = false;
|
rt300@21
|
47 playsCandidate = false;
|
rt300@21
|
48
|
rt300@22
|
49 showsCountDown = true;
|
rt300@21
|
50
|
rt300@21
|
51 isLastOfSeq = false;
|
rt300@21
|
52 isLastOfRun = false;
|
rt300@21
|
53 isLastOfAll = false;
|
rt300@21
|
54 presetIndex = -1;
|
rt300@21
|
55 seqNumber = -1;
|
rt300@21
|
56 runNumber = -1;
|
rt300@21
|
57
|
rt300@21
|
58 tempo = MIN_TEMPO;
|
rt300@21
|
59 }
|
rt300@22
|
60 void Step::setAsBlankCounter(){
|
rt300@22
|
61 type = COUNT_IN;
|
rt300@22
|
62 showsTargetIcon = false;
|
rt300@22
|
63 showsControlSettings = false;
|
rt300@22
|
64 showsControlGuides = false;
|
rt300@22
|
65 showsMatchResults = false;
|
rt300@22
|
66 hidesSliders = true;
|
rt300@22
|
67 isPreview = false;
|
rt300@22
|
68
|
rt300@22
|
69 allowsCandidateControl = false;
|
rt300@22
|
70 playsTarget = false;
|
rt300@22
|
71 playsCandidate = false;
|
rt300@22
|
72 showsCountDown = true;
|
rt300@22
|
73
|
rt300@22
|
74 }
|
rt300@22
|
75 void Step::setAsPreviewPreparer(){
|
rt300@22
|
76 type = PREVIEW_PREPARER;
|
rt300@21
|
77 showsTargetIcon = true;
|
rt300@22
|
78 showsControlSettings = false;
|
rt300@27
|
79 showsControlGuides = true;
|
rt300@27
|
80
|
rt300@21
|
81 showsMatchResults = false;
|
rt300@22
|
82 hidesSliders = true;
|
rt300@21
|
83 isPreview = true;
|
rt300@21
|
84
|
rt300@26
|
85 allowsCandidateControl = true;
|
rt300@21
|
86 playsTarget = true;
|
rt300@21
|
87 playsCandidate = false;
|
rt300@22
|
88 showsCountDown = true;
|
rt300@21
|
89 }
|
rt300@22
|
90
|
rt300@21
|
91 void Step::setAsPreviewPlayer(){
|
rt300@22
|
92 type = PREVIEW_DISPLAYER;
|
rt300@21
|
93 showsTargetIcon = true;
|
rt300@26
|
94 showsControlSettings = false;
|
rt300@26
|
95 showsControlGuides = true;
|
rt300@21
|
96 showsMatchResults = false;
|
rt300@22
|
97 hidesSliders = false;
|
rt300@22
|
98
|
rt300@21
|
99 isPreview = true;
|
rt300@21
|
100
|
rt300@26
|
101 allowsCandidateControl = true;
|
rt300@21
|
102 playsTarget = true;
|
rt300@21
|
103 playsCandidate = false;
|
rt300@21
|
104
|
rt300@22
|
105 showsCountDown = false;
|
rt300@21
|
106 }
|
rt300@22
|
107
|
rt300@21
|
108 void Step::setAsMatchingPreparer(){
|
rt300@22
|
109 // just a count down
|
rt300@22
|
110 type = MATCHING_PREPARER;
|
rt300@22
|
111 showsTargetIcon = true;
|
rt300@22
|
112 showsControlSettings = false;
|
rt300@22
|
113 showsControlGuides = false;
|
rt300@22
|
114 showsMatchResults = false;
|
rt300@22
|
115 hidesSliders = true;
|
rt300@22
|
116
|
rt300@22
|
117 isPreview = false;
|
rt300@22
|
118
|
rt300@26
|
119 allowsCandidateControl = true;
|
rt300@22
|
120 playsTarget = true;
|
rt300@22
|
121 playsCandidate = false;
|
rt300@22
|
122
|
rt300@22
|
123 showsCountDown = true;
|
rt300@22
|
124 }
|
rt300@22
|
125 void Step::setAsMatchingInteraction(){
|
rt300@21
|
126 type = MATCHING_INTERACTION;
|
rt300@21
|
127 showsTargetIcon = true;
|
rt300@21
|
128 showsControlSettings = false;
|
rt300@23
|
129 showsControlGuides = true;
|
rt300@21
|
130 showsMatchResults = false;
|
rt300@22
|
131 hidesSliders = false;
|
rt300@21
|
132 isPreview = false;
|
rt300@21
|
133
|
rt300@21
|
134 allowsCandidateControl = true;
|
rt300@21
|
135 playsTarget = false;
|
rt300@22
|
136 playsCandidate = false; // ??
|
rt300@21
|
137
|
rt300@22
|
138 showsCountDown = false;
|
rt300@21
|
139 }
|
rt300@22
|
140 void Step::setAsMatchingFeedback(){
|
rt300@22
|
141 type = MATCHING_INTERACTION;
|
rt300@22
|
142 showsTargetIcon = false;
|
rt300@21
|
143 showsControlSettings = false;
|
rt300@22
|
144 showsControlGuides = false;
|
rt300@22
|
145 showsMatchResults = true;
|
rt300@22
|
146 hidesSliders = true;
|
rt300@21
|
147 isPreview = false;
|
rt300@21
|
148
|
rt300@21
|
149 allowsCandidateControl = false;
|
rt300@21
|
150 playsTarget = false;
|
rt300@22
|
151 playsCandidate = true; // ??
|
rt300@21
|
152
|
rt300@22
|
153 showsCountDown = false;
|
rt300@21
|
154 }
|
rt300@21
|
155
|
rt300@21
|
156 //=================================================================
|
rt300@21
|
157 //=================================================================
|
rt300@21
|
158 //=================================================================
|
rt300@21
|
159
|
rt300@21
|
160 SequenceController::SequenceController(){
|
rt300@51
|
161 int tie[] = {
|
rt300@44
|
162 2500,
|
rt300@44
|
163 1944,
|
rt300@44
|
164 1590,
|
rt300@44
|
165 1346,
|
rt300@44
|
166 1166,
|
rt300@44
|
167 1029,
|
rt300@44
|
168 921,
|
rt300@44
|
169 833,
|
rt300@44
|
170 760,
|
rt300@44
|
171 700,
|
rt300@44
|
172 648,
|
rt300@44
|
173 603,
|
rt300@44
|
174 564,
|
rt300@44
|
175 530,
|
rt300@44
|
176 500
|
rt300@43
|
177 };
|
rt300@51
|
178
|
rt300@51
|
179 int tih[] = {
|
rt300@51
|
180 800,
|
rt300@51
|
181 700,
|
rt300@51
|
182 608,
|
rt300@51
|
183 538,
|
rt300@51
|
184 482,
|
rt300@51
|
185 437,
|
rt300@51
|
186 400,
|
rt300@51
|
187 368,
|
rt300@51
|
188 341,
|
rt300@51
|
189 327,
|
rt300@51
|
190 311,
|
rt300@51
|
191 296,
|
rt300@51
|
192 283,
|
rt300@51
|
193 271,
|
rt300@51
|
194 260,
|
rt300@51
|
195 250,
|
rt300@51
|
196 243,
|
rt300@51
|
197 236,
|
rt300@51
|
198 230,
|
rt300@51
|
199 225,
|
rt300@51
|
200 220,
|
rt300@51
|
201 215,
|
rt300@51
|
202 210,
|
rt300@51
|
203 205,
|
rt300@51
|
204 200
|
rt300@51
|
205
|
rt300@51
|
206 };
|
rt300@51
|
207
|
rt300@51
|
208
|
rt300@51
|
209
|
rt300@44
|
210 for(int i = 0; i < NUM_TEMPO_STEPS; i++){
|
rt300@51
|
211 timeIntervalsHard.push_back(tie[i]);
|
rt300@43
|
212 }
|
rt300@44
|
213
|
rt300@43
|
214
|
rt300@43
|
215 currentRunNumber = 0; // actually goes from 1 0 is pre-start
|
rt300@43
|
216
|
rt300@32
|
217 };
|
rt300@32
|
218 //-------------------------------------------------------------------
|
rt300@47
|
219 void SequenceController::init(bool asoundOnlyMode, controlPanelType whichInterfaceAreWeUsing, bool ademoMode){
|
rt300@47
|
220 demoMode = ademoMode;
|
rt300@32
|
221 soundOnlyMode = asoundOnlyMode;
|
rt300@43
|
222 panelType = whichInterfaceAreWeUsing;
|
rt300@21
|
223 tempoInc = float(MAX_TEMPO - MIN_TEMPO) / float(NUM_TEMPO_STEPS);
|
rt300@36
|
224 timeInc = (MAX_TIME - MIN_TIME) / NUM_TEMPO_STEPS;
|
rt300@43
|
225
|
rt300@47
|
226 if (!demoMode){
|
rt300@50
|
227 generateSteps12();
|
rt300@43
|
228 }else{
|
rt300@45
|
229 generateTestSequence(1);
|
rt300@45
|
230 generateTestSequence(2);
|
rt300@49
|
231 generateTestSequence(3);
|
rt300@43
|
232 }
|
rt300@43
|
233
|
rt300@21
|
234 setToStart();
|
rt300@43
|
235
|
rt300@21
|
236 };
|
rt300@48
|
237
|
rt300@48
|
238 void SequenceController::clearAll(){
|
rt300@48
|
239 steps.clear();
|
rt300@48
|
240 totNumRuns = 0;
|
rt300@48
|
241 currentRunNumber = 0;
|
rt300@48
|
242 currentStep = steps.begin();
|
rt300@48
|
243
|
rt300@48
|
244 }
|
rt300@32
|
245 //-------------------------------------------------------------------
|
rt300@27
|
246 AnimStep SequenceController::getNextStep(){
|
rt300@21
|
247
|
rt300@21
|
248 currentStep++;
|
rt300@21
|
249 if ((*currentStep).isLastOfRun){
|
rt300@21
|
250 // uh
|
rt300@21
|
251 }
|
rt300@21
|
252 if ((*currentStep).isLastOfSeq){
|
rt300@21
|
253
|
rt300@21
|
254 }
|
rt300@21
|
255 return (*currentStep);
|
rt300@21
|
256
|
rt300@21
|
257 };
|
rt300@27
|
258 //-------------------------------------------------------------------
|
rt300@21
|
259 void SequenceController::setToStart(){
|
rt300@21
|
260 currentStep = steps.begin();
|
rt300@43
|
261 currentRunNumber = (*currentStep).runNumber;
|
rt300@43
|
262 }
|
rt300@43
|
263 //-------------------------------------------------------------------
|
rt300@43
|
264 void SequenceController::skipRun(){
|
rt300@43
|
265 // loop thru steps until next run reached
|
rt300@47
|
266 if ( (*currentStep).isLastOfAll || (*currentStep).runNumber >= totNumRuns){
|
rt300@50
|
267 setToStart();
|
rt300@44
|
268 return;
|
rt300@44
|
269 }
|
rt300@44
|
270 currentStep++; // IGNORE CURRENT STEP (LAST OF OLD RUN)
|
rt300@44
|
271
|
rt300@43
|
272 bool nextRunReached = false;
|
rt300@43
|
273
|
rt300@43
|
274 while (!nextRunReached){
|
rt300@43
|
275 currentStep++;
|
rt300@44
|
276 if ( (*currentStep).isLastOfAll){
|
rt300@50
|
277 setToStart();
|
rt300@44
|
278 return;
|
rt300@44
|
279 }
|
rt300@43
|
280 if ((*currentStep).runNumber != currentRunNumber && (*currentStep).runNumber != 0){
|
rt300@43
|
281 nextRunReached = true;
|
rt300@43
|
282 currentRunNumber = (*currentStep).runNumber;
|
rt300@43
|
283 }
|
rt300@43
|
284 }
|
rt300@21
|
285 }
|
rt300@27
|
286 //-------------------------------------------------------------------
|
rt300@21
|
287 void SequenceController::stepForward(){
|
rt300@21
|
288 currentStep++;
|
rt300@21
|
289 };
|
rt300@27
|
290 //-------------------------------------------------------------------
|
rt300@43
|
291 float SequenceController::getStartIntervalTime(){
|
rt300@43
|
292 float t = timeIntervalsHard[0];
|
rt300@43
|
293 if (panelType == ALL_SLIDERS){
|
rt300@44
|
294 t = SLIDER_SLOW_FACTOR*t;
|
rt300@43
|
295 }
|
rt300@47
|
296 if(demoMode){
|
rt300@47
|
297 t = 2*t;
|
rt300@47
|
298 }
|
rt300@43
|
299 return t;
|
rt300@21
|
300 }
|
rt300@27
|
301 //-------------------------------------------------------------------
|
rt300@21
|
302 void SequenceController::generateSteps(){
|
rt300@21
|
303 srand (time(NULL));
|
rt300@21
|
304
|
rt300@43
|
305 int run = 1;
|
rt300@21
|
306
|
rt300@21
|
307
|
rt300@21
|
308
|
rt300@21
|
309 for(int numInSequence = MIN_TARGETS_IN_SEQUENCE; numInSequence <= MAX_TARGETS_IN_SEQUENCE; numInSequence++){
|
rt300@36
|
310
|
rt300@36
|
311 for(int rep = 0; rep < NUM_REPETITIONS_AT_LEVEL; rep++){
|
rt300@43
|
312
|
rt300@43
|
313 generateCountIn(1,run);
|
rt300@43
|
314
|
rt300@43
|
315 if (soundOnlyMode){
|
rt300@43
|
316 generateASoundOnlyRun(run, numInSequence);
|
rt300@43
|
317 }else {
|
rt300@43
|
318 generateRun(run, numInSequence);
|
rt300@43
|
319 }
|
rt300@43
|
320 steps.back().isLastOfRun = true;
|
rt300@43
|
321 run++;
|
rt300@43
|
322 cout << "-generate run finished-" << endl;
|
rt300@36
|
323 }
|
rt300@21
|
324 }
|
rt300@44
|
325 totNumRuns = run-1;
|
rt300@21
|
326 steps.back().isLastOfAll = true;
|
rt300@21
|
327 };
|
rt300@50
|
328 //-------------------------------------------------------------------
|
rt300@50
|
329 void SequenceController::generateSteps12(){
|
rt300@50
|
330 srand (time(NULL));
|
rt300@50
|
331
|
rt300@50
|
332 int run = 1;
|
rt300@50
|
333
|
rt300@50
|
334 for(int rep = 0; rep < 4; rep++){
|
rt300@50
|
335
|
rt300@50
|
336 for(int numInSequence = 1; numInSequence <= 3; numInSequence++){
|
rt300@50
|
337
|
rt300@50
|
338 generateCountIn(1,run);
|
rt300@50
|
339
|
rt300@50
|
340 generateRun(run, numInSequence);
|
rt300@50
|
341
|
rt300@50
|
342 steps.back().isLastOfRun = true;
|
rt300@50
|
343 run++;
|
rt300@50
|
344 cout << "-generate run finished-" << endl;
|
rt300@50
|
345 }
|
rt300@50
|
346 }
|
rt300@50
|
347 totNumRuns = run-1;
|
rt300@50
|
348 steps.back().isLastOfAll = true;
|
rt300@50
|
349 };
|
rt300@27
|
350
|
rt300@27
|
351 //-------------------------------------------------------------------
|
rt300@45
|
352 void SequenceController::generateTestSequence(int run){
|
rt300@43
|
353 // just make something simple to check sanity
|
rt300@50
|
354 generateCountIn(1,run);
|
rt300@43
|
355
|
rt300@49
|
356 vector<int> seq = randomSequence(run);
|
rt300@43
|
357
|
rt300@43
|
358 // first we have a preparation count in
|
rt300@43
|
359 AnimStep nextStep;
|
rt300@43
|
360 nextStep.presetIndex = -1; // minus one means "blank"
|
rt300@47
|
361 nextStep.runNumber = run;
|
rt300@43
|
362 nextStep.seqNumber = 1;
|
rt300@43
|
363 nextStep.whichInSequence = 0;
|
rt300@43
|
364 //nextStep.tempo = curTempo;
|
rt300@43
|
365 nextStep.tempoLevel = 0;
|
rt300@43
|
366 // nextStep.setTimeFromTempo();
|
rt300@47
|
367 nextStep.timeAllowedMs = getStartIntervalTime();
|
rt300@43
|
368 nextStep.setTempoFromTime();
|
rt300@43
|
369 nextStep.showsGuides = true;
|
rt300@43
|
370 nextStep.difficulty = 0;
|
rt300@43
|
371 nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
|
rt300@43
|
372 nextStep.showsResultsAtEnd = false;
|
rt300@43
|
373
|
rt300@45
|
374 steps.push_back(nextStep);
|
rt300@43
|
375
|
rt300@43
|
376 makePreview(seq, 0, nextStep);
|
rt300@27
|
377
|
rt300@43
|
378 makeGuidedSequence(seq, 0, nextStep);
|
rt300@47
|
379 makeGuidedSequence(seq, 0, nextStep);
|
rt300@43
|
380
|
rt300@43
|
381 makeMatchingSequence(seq, 0, nextStep);
|
rt300@47
|
382 makeMatchingSequence(seq, 0, nextStep);
|
rt300@47
|
383 nextStep.type = AnimStep::MATCHING_NEUTRAL_COUNT;
|
rt300@47
|
384 steps.push_back(nextStep);
|
rt300@47
|
385
|
rt300@47
|
386 makePreview(seq, 0, nextStep);
|
rt300@47
|
387
|
rt300@47
|
388 makeGuidedSequence(seq, 0, nextStep);
|
rt300@47
|
389 makeGuidedSequence(seq, 0, nextStep);
|
rt300@47
|
390
|
rt300@47
|
391 makeMatchingSequence(seq, 0, nextStep);
|
rt300@47
|
392 makeMatchingSequence(seq, 0, nextStep);
|
rt300@50
|
393 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@47
|
394 steps.push_back(nextStep);
|
rt300@43
|
395
|
rt300@45
|
396 totNumRuns = run;
|
rt300@45
|
397 steps.back().isLastOfRun = true;
|
rt300@43
|
398
|
rt300@43
|
399 }
|
rt300@43
|
400 //-------------------------------------------------------------------
|
rt300@43
|
401
|
rt300@43
|
402
|
rt300@43
|
403 void SequenceController::generateCountIn(int countInLength, int runNumber){
|
rt300@27
|
404 AnimStep countStep;
|
rt300@21
|
405 for (int i = 0; i < countInLength; i++){
|
rt300@27
|
406 countStep.whichInSequence = countInLength - i + 1;
|
rt300@27
|
407 countStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
|
rt300@36
|
408 countStep.showsResultsAtEnd = false;
|
rt300@43
|
409 countStep.runNumber = runNumber;
|
rt300@43
|
410 countStep.timeAllowedMs = getStartIntervalTime();
|
rt300@43
|
411 countStep.setTempoFromTime();
|
rt300@21
|
412 steps.push_back(countStep);
|
rt300@21
|
413
|
rt300@21
|
414 }
|
rt300@21
|
415 };
|
rt300@27
|
416
|
rt300@27
|
417 //-------------------------------------------------------------------
|
rt300@27
|
418
|
rt300@27
|
419
|
rt300@27
|
420 vector<int> SequenceController::randomSequence(int numInSequence){
|
rt300@27
|
421 vector<int> stepPresetIndices;
|
rt300@27
|
422 // get some random ints
|
rt300@27
|
423 for(int n=0; n < numInSequence; n++){
|
rt300@27
|
424 int nextPreset = getRandomButNot(NUM_PRESETS,stepPresetIndices);
|
rt300@27
|
425 stepPresetIndices.push_back(nextPreset);
|
rt300@27
|
426 cout << nextPreset << ",";
|
rt300@27
|
427 }
|
rt300@27
|
428
|
rt300@27
|
429 return stepPresetIndices;
|
rt300@27
|
430 }
|
rt300@27
|
431
|
rt300@32
|
432 vector<int> SequenceController::nonRandomSequence(int numInSequence){
|
rt300@32
|
433 vector<int> stepPresetIndices;
|
rt300@43
|
434 // 1,2,3,4 you know the score
|
rt300@32
|
435 for(int n=0; n < numInSequence; n++){
|
rt300@32
|
436 int nextPreset = n;
|
rt300@32
|
437 stepPresetIndices.push_back(nextPreset);
|
rt300@32
|
438 cout << nextPreset << ",";
|
rt300@32
|
439 }
|
rt300@32
|
440
|
rt300@32
|
441 return stepPresetIndices;
|
rt300@32
|
442 }
|
rt300@34
|
443 //-------------------------------------------------------------------
|
rt300@32
|
444
|
rt300@41
|
445 void SequenceController::generateRun(int run, int numInSequence){
|
rt300@34
|
446 float curTempo = MIN_TEMPO;
|
rt300@34
|
447 int seqNo = 0;
|
rt300@34
|
448 AnimStep nextStep;
|
rt300@34
|
449 for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){
|
rt300@34
|
450
|
rt300@34
|
451
|
rt300@34
|
452
|
rt300@34
|
453 // first we have a preparation count in
|
rt300@34
|
454 nextStep.presetIndex = -1; // minus one means "blank"
|
rt300@34
|
455 nextStep.runNumber = run;
|
rt300@34
|
456 nextStep.seqNumber = seqNo;
|
rt300@34
|
457 nextStep.whichInSequence = 0;
|
rt300@43
|
458 //nextStep.tempo = curTempo;
|
rt300@36
|
459 nextStep.tempoLevel = tempoLevel;
|
rt300@43
|
460 // nextStep.setTimeFromTempo();
|
rt300@43
|
461 nextStep.timeAllowedMs = timeIntervalsHard[tempoLevel];
|
rt300@43
|
462 if (panelType == ALL_SLIDERS){
|
rt300@44
|
463 nextStep.timeAllowedMs = SLIDER_SLOW_FACTOR*nextStep.timeAllowedMs;
|
rt300@43
|
464 }
|
rt300@43
|
465 nextStep.setTempoFromTime();
|
rt300@34
|
466 nextStep.showsGuides = true;
|
rt300@35
|
467 nextStep.difficulty = 0;
|
rt300@34
|
468 nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
|
rt300@34
|
469 nextStep.showsResultsAtEnd = false;
|
rt300@41
|
470
|
rt300@41
|
471 //nextStep = makeFirstCountIn();
|
rt300@34
|
472 steps.push_back(nextStep);
|
rt300@44
|
473
|
rt300@44
|
474 // two bar coun tin
|
rt300@44
|
475 steps.push_back(nextStep);
|
rt300@44
|
476
|
rt300@39
|
477
|
rt300@39
|
478
|
rt300@34
|
479 // generate a sequence of random preset indices
|
rt300@34
|
480 vector<int> stepPresetIndices = randomSequence(numInSequence);
|
rt300@34
|
481 nextStep.thisSequence = stepPresetIndices;
|
rt300@43
|
482 nextStep.totalLengthOfSeq = numInSequence;
|
rt300@41
|
483 makePreview(stepPresetIndices, run, nextStep);
|
rt300@34
|
484
|
rt300@41
|
485 // make GUIDED sequence (1 and 2)
|
rt300@41
|
486 makeGuidedSequence(stepPresetIndices, run, nextStep);
|
rt300@41
|
487 makeGuidedSequence(stepPresetIndices, run, nextStep);
|
rt300@34
|
488
|
rt300@41
|
489 // make matching sequence without icon seq help
|
rt300@41
|
490 makeMatchingSequence(stepPresetIndices, run, nextStep);
|
rt300@41
|
491 makeMatchingSequence(stepPresetIndices, run, nextStep);
|
rt300@34
|
492
|
rt300@34
|
493 steps.back().isLastOfSeq = true;
|
rt300@41
|
494 if(numInSequence == 1){
|
rt300@44
|
495 curTempo += tempoInc; // make no 1 easier!!!??? will mess up time points
|
rt300@41
|
496 }else{
|
rt300@41
|
497 curTempo += tempoInc;
|
rt300@41
|
498 }
|
rt300@34
|
499 seqNo++;
|
rt300@34
|
500 cout << endl;
|
rt300@34
|
501
|
rt300@34
|
502 }
|
rt300@43
|
503
|
rt300@34
|
504 // ANIM nextStep.setAsBlankCounter();
|
rt300@34
|
505 nextStep.type = AnimStep::MATCHING_NEUTRAL_COUNT;
|
rt300@34
|
506 steps.push_back(nextStep);
|
rt300@34
|
507
|
rt300@34
|
508 }
|
rt300@41
|
509 void SequenceController::makePreview(vector<int> stepPresetIndices, int run, AnimStep& nextStep){
|
rt300@41
|
510
|
rt300@41
|
511 // MAKE PREVIEW
|
rt300@41
|
512 int n = 1;
|
rt300@41
|
513 for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
|
rt300@41
|
514 // put loader
|
rt300@41
|
515
|
rt300@41
|
516 nextStep.presetIndex = *si;
|
rt300@41
|
517 nextStep.runNumber = run;
|
rt300@41
|
518 nextStep.whichInSequence = n;
|
rt300@42
|
519 if (soundOnlyMode){
|
rt300@42
|
520 nextStep.showsGuides = false;
|
rt300@42
|
521 nextStep.showsIcons = false ;
|
rt300@42
|
522 }else{
|
rt300@42
|
523 nextStep.showsGuides = true;
|
rt300@42
|
524 nextStep.showsIcons = true;
|
rt300@42
|
525 }
|
rt300@41
|
526 nextStep.showsResultsAtEnd = false;
|
rt300@41
|
527 nextStep.type = AnimStep::PREVIEW_MOVE;
|
rt300@41
|
528 steps.push_back(nextStep);
|
rt300@41
|
529
|
rt300@41
|
530 n++;
|
rt300@41
|
531 }
|
rt300@41
|
532
|
rt300@41
|
533 // move back to neutral
|
rt300@41
|
534 nextStep.presetIndex = -1;
|
rt300@41
|
535 nextStep.type = AnimStep::PREVIEW_LAST;
|
rt300@41
|
536 nextStep.whichInSequence = 0;
|
rt300@41
|
537 nextStep.difficulty = 0;
|
rt300@41
|
538 nextStep.showsResultsAtEnd = true;
|
rt300@41
|
539 steps.push_back(nextStep);
|
rt300@41
|
540 }
|
rt300@41
|
541 void SequenceController::makeGuidedSequence(vector<int> stepPresetIndices, int run, AnimStep& nextStep){
|
rt300@41
|
542 int n = 1;
|
rt300@41
|
543 for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
|
rt300@41
|
544 // put loader
|
rt300@41
|
545 nextStep.difficulty = 1;
|
rt300@41
|
546 nextStep.presetIndex = *si;
|
rt300@41
|
547 nextStep.runNumber = run;
|
rt300@41
|
548 nextStep.whichInSequence = n;
|
rt300@41
|
549 nextStep.showsGuides = true;
|
rt300@41
|
550 nextStep.showsIcons = true;
|
rt300@41
|
551 nextStep.showsResultsAtEnd = true;
|
rt300@41
|
552 nextStep.type = AnimStep::MATCHING_MOVE;
|
rt300@41
|
553 steps.push_back(nextStep);
|
rt300@41
|
554
|
rt300@41
|
555 if (SPACER_BARS){
|
rt300@41
|
556 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@41
|
557 steps.push_back(nextStep);
|
rt300@41
|
558 }
|
rt300@41
|
559 n++;
|
rt300@41
|
560 }
|
rt300@41
|
561 // move back to neutral
|
rt300@41
|
562 nextStep.presetIndex = -1;
|
rt300@41
|
563 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@41
|
564 nextStep.showsGuides = true;
|
rt300@41
|
565 nextStep.showsIcons = true;
|
rt300@41
|
566 nextStep.whichInSequence = END_NEUTRAL_MATCH;
|
rt300@41
|
567 nextStep.difficulty = 0;
|
rt300@41
|
568 nextStep.showsResultsAtEnd = true;
|
rt300@41
|
569 steps.push_back(nextStep);
|
rt300@41
|
570 }
|
rt300@41
|
571 void SequenceController::makeMatchingSequence(vector<int> stepPresetIndices, int run, AnimStep& nextStep){
|
rt300@41
|
572 int n = 1;
|
rt300@41
|
573 for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
|
rt300@41
|
574 // put loader
|
rt300@42
|
575 if(soundOnlyMode){
|
rt300@42
|
576 nextStep.difficulty = 3;
|
rt300@42
|
577 }else{
|
rt300@42
|
578 nextStep.difficulty = 2;
|
rt300@42
|
579 }
|
rt300@41
|
580 nextStep.presetIndex = *si;
|
rt300@41
|
581 nextStep.runNumber = run;
|
rt300@41
|
582 nextStep.whichInSequence = n;
|
rt300@41
|
583 nextStep.showsGuides = false;
|
rt300@41
|
584 nextStep.showsIcons = false;
|
rt300@41
|
585 nextStep.showsResultsAtEnd = true;
|
rt300@41
|
586 nextStep.type = AnimStep::MATCHING_MOVE;
|
rt300@41
|
587 steps.push_back(nextStep);
|
rt300@41
|
588
|
rt300@41
|
589 if (SPACER_BARS){
|
rt300@41
|
590 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@41
|
591 steps.push_back(nextStep);
|
rt300@41
|
592 }
|
rt300@41
|
593 n++;
|
rt300@41
|
594 }
|
rt300@41
|
595 // move back to neutral
|
rt300@41
|
596 nextStep.presetIndex = -1;
|
rt300@41
|
597 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@41
|
598 nextStep.whichInSequence = END_NEUTRAL_MATCH;
|
rt300@41
|
599 nextStep.difficulty = 0;
|
rt300@41
|
600 nextStep.showsGuides = false; // fact that preset is -1 indicates end of each seq
|
rt300@41
|
601 nextStep.showsIcons = false;
|
rt300@41
|
602 nextStep.showsResultsAtEnd = true; // to record neutral hit
|
rt300@41
|
603 steps.push_back(nextStep);
|
rt300@41
|
604 }
|
rt300@32
|
605 //-------------------------------------------------------------------
|
rt300@32
|
606 void SequenceController::generateASoundOnlyRun(int run, int numInSequence){
|
rt300@32
|
607
|
rt300@32
|
608 // here the preview is sound only
|
rt300@32
|
609 float curTempo = MIN_TEMPO;
|
rt300@32
|
610 int seqNo = 0;
|
rt300@32
|
611 AnimStep nextStep;
|
rt300@43
|
612 nextStep.totalLengthOfSeq = numInSequence;
|
rt300@43
|
613
|
rt300@32
|
614 for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){
|
rt300@32
|
615 // first we have a preparation count in
|
rt300@32
|
616 nextStep.presetIndex = -1; // minus one means "blank"
|
rt300@32
|
617 nextStep.runNumber = run;
|
rt300@32
|
618 nextStep.seqNumber = seqNo;
|
rt300@32
|
619 nextStep.whichInSequence = 0;
|
rt300@43
|
620
|
rt300@35
|
621 nextStep.difficulty = 0;
|
rt300@48
|
622 nextStep.timeAllowedMs = timeIntervalsHard[tempoLevel];
|
rt300@48
|
623 nextStep.setTempoFromTime();
|
rt300@32
|
624 nextStep.showsGuides = true; // guide shown for neutral point
|
rt300@32
|
625 nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
|
rt300@32
|
626 nextStep.showsResultsAtEnd = false;
|
rt300@32
|
627 steps.push_back(nextStep);
|
rt300@32
|
628
|
rt300@32
|
629 // generate a sequence of random preset indices
|
rt300@32
|
630 vector<int> stepPresetIndices = randomSequence(numInSequence);
|
rt300@32
|
631 nextStep.thisSequence = stepPresetIndices;
|
rt300@32
|
632
|
rt300@42
|
633 makePreview(stepPresetIndices, run, nextStep);
|
rt300@43
|
634 makePreview(stepPresetIndices, run, nextStep);
|
rt300@32
|
635
|
rt300@42
|
636 // make matching sequence without icon seq help
|
rt300@42
|
637 makeMatchingSequence(stepPresetIndices, run, nextStep);
|
rt300@42
|
638 makeMatchingSequence(stepPresetIndices, run, nextStep);
|
rt300@32
|
639
|
rt300@32
|
640
|
rt300@32
|
641 steps.back().isLastOfSeq = true;
|
rt300@32
|
642 curTempo += tempoInc;
|
rt300@32
|
643 seqNo++;
|
rt300@32
|
644 }
|
rt300@32
|
645 // shows last result ?
|
rt300@32
|
646 nextStep.type = AnimStep::MATCHING_NEUTRAL_COUNT;
|
rt300@32
|
647 steps.push_back(nextStep);
|
rt300@32
|
648 }
|
rt300@27
|
649 //-------------------------------------------------------------------
|
rt300@27
|
650
|
rt300@21
|
651 void SequenceController::generateARun(int run, int numInSequence){
|
rt300@21
|
652 float curTempo = MIN_TEMPO;
|
rt300@21
|
653 int seqNo = 0;
|
rt300@27
|
654 AnimStep nextStep;
|
rt300@21
|
655 for(int tempoLevel = 0; tempoLevel < NUM_TEMPO_STEPS; tempoLevel++){
|
rt300@21
|
656
|
rt300@22
|
657
|
rt300@22
|
658
|
rt300@22
|
659 // first we have a preparation count in
|
rt300@22
|
660 nextStep.presetIndex = -1; // minus one means "blank"
|
rt300@22
|
661 nextStep.runNumber = run;
|
rt300@22
|
662 nextStep.seqNumber = seqNo;
|
rt300@27
|
663 nextStep.whichInSequence = 0;
|
rt300@22
|
664 nextStep.tempo = curTempo;
|
rt300@36
|
665 nextStep.tempoLevel = tempoLevel;
|
rt300@36
|
666 nextStep.setTimeFromTempo();
|
rt300@38
|
667 nextStep.showsGuides = false;
|
rt300@27
|
668 nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT;
|
rt300@31
|
669 nextStep.showsResultsAtEnd = false;
|
rt300@38
|
670 // two neutrals between the new sequences
|
rt300@38
|
671 steps.push_back(nextStep);
|
rt300@38
|
672 nextStep.showsGuides = true;
|
rt300@27
|
673 steps.push_back(nextStep);
|
rt300@22
|
674
|
rt300@27
|
675 // generate a sequence of random preset indices
|
rt300@27
|
676 vector<int> stepPresetIndices = randomSequence(numInSequence);
|
rt300@27
|
677 nextStep.thisSequence = stepPresetIndices;
|
rt300@43
|
678
|
rt300@22
|
679 // make preview sequence
|
rt300@35
|
680 int n = 1;
|
rt300@22
|
681 for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
|
rt300@21
|
682 // put loader
|
rt300@21
|
683
|
rt300@21
|
684 nextStep.presetIndex = *si;
|
rt300@21
|
685 nextStep.runNumber = run;
|
rt300@21
|
686 nextStep.seqNumber = seqNo;
|
rt300@27
|
687 nextStep.whichInSequence = n;
|
rt300@43
|
688
|
rt300@27
|
689 nextStep.showsGuides = true;
|
rt300@31
|
690 nextStep.showsIcons = true;
|
rt300@31
|
691 nextStep.showsResultsAtEnd = false;
|
rt300@27
|
692 nextStep.type = AnimStep::PREVIEW_MOVE;
|
rt300@21
|
693 steps.push_back(nextStep);
|
rt300@21
|
694
|
rt300@29
|
695 if (SPACER_BARS){
|
rt300@35
|
696 nextStep.type = AnimStep::PREVIEW_LAST;
|
rt300@29
|
697 steps.push_back(nextStep);
|
rt300@29
|
698 }
|
rt300@21
|
699 n++;
|
rt300@21
|
700 }
|
rt300@27
|
701
|
rt300@31
|
702 // move back to neutral
|
rt300@31
|
703 nextStep.presetIndex = -1;
|
rt300@31
|
704 nextStep.type = AnimStep::PREVIEW_MOVE;
|
rt300@35
|
705 nextStep.difficulty = 0;
|
rt300@35
|
706 nextStep.whichInSequence = 0;
|
rt300@35
|
707 nextStep.showsResultsAtEnd = true;
|
rt300@27
|
708 steps.push_back(nextStep);
|
rt300@22
|
709
|
rt300@31
|
710 // make GUIDED sequence
|
rt300@35
|
711 n = 1;
|
rt300@31
|
712 for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
|
rt300@31
|
713 // put loader
|
rt300@35
|
714 nextStep.difficulty = 1;
|
rt300@31
|
715 nextStep.presetIndex = *si;
|
rt300@31
|
716 nextStep.seqNumber = seqNo;
|
rt300@31
|
717 nextStep.whichInSequence = n;
|
rt300@43
|
718
|
rt300@31
|
719 nextStep.showsGuides = true;
|
rt300@31
|
720 nextStep.showsIcons = true;
|
rt300@31
|
721 nextStep.showsResultsAtEnd = true;
|
rt300@35
|
722 nextStep.type = AnimStep::MATCHING_MOVE;
|
rt300@31
|
723 steps.push_back(nextStep);
|
rt300@43
|
724
|
rt300@31
|
725 if (SPACER_BARS){
|
rt300@35
|
726 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@31
|
727 steps.push_back(nextStep);
|
rt300@31
|
728 }
|
rt300@31
|
729 n++;
|
rt300@31
|
730 }
|
rt300@31
|
731 // move back to neutral
|
rt300@31
|
732 nextStep.presetIndex = -1;
|
rt300@39
|
733 nextStep.whichInSequence = 0;
|
rt300@35
|
734 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@31
|
735 nextStep.showsResultsAtEnd = false;
|
rt300@31
|
736 steps.push_back(nextStep);
|
rt300@31
|
737
|
rt300@38
|
738
|
rt300@31
|
739 // make matching sequence with icon seq help
|
rt300@35
|
740 n = 1;
|
rt300@22
|
741 for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
|
rt300@21
|
742 // put loader
|
rt300@35
|
743 nextStep.difficulty = 2;
|
rt300@21
|
744 nextStep.presetIndex = *si;
|
rt300@27
|
745 nextStep.whichInSequence = n;
|
rt300@43
|
746
|
rt300@31
|
747 nextStep.showsGuides = false;
|
rt300@31
|
748 nextStep.showsIcons = true;
|
rt300@27
|
749 nextStep.type = AnimStep::MATCHING_MOVE;
|
rt300@31
|
750 nextStep.showsResultsAtEnd = true;
|
rt300@22
|
751 steps.push_back(nextStep);
|
rt300@21
|
752
|
rt300@29
|
753 if (SPACER_BARS){
|
rt300@35
|
754 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@29
|
755 steps.push_back(nextStep);
|
rt300@43
|
756
|
rt300@29
|
757 }
|
rt300@21
|
758 n++;
|
rt300@43
|
759
|
rt300@21
|
760 }
|
rt300@21
|
761
|
rt300@31
|
762 // move back to neutral
|
rt300@31
|
763 nextStep.presetIndex = -1;
|
rt300@39
|
764 nextStep.whichInSequence = 0;
|
rt300@35
|
765 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@31
|
766 nextStep.showsResultsAtEnd = false;
|
rt300@31
|
767 steps.push_back(nextStep);
|
rt300@31
|
768
|
rt300@31
|
769 // make matching sequence WITHOUT icon seq help
|
rt300@35
|
770 n = 1;
|
rt300@31
|
771 for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){
|
rt300@31
|
772 // put loader
|
rt300@35
|
773 nextStep.difficulty = 3;
|
rt300@31
|
774 nextStep.presetIndex = *si;
|
rt300@31
|
775 nextStep.whichInSequence = n;
|
rt300@31
|
776
|
rt300@31
|
777 nextStep.showsGuides = false;
|
rt300@35
|
778 nextStep.showsIcons = false;
|
rt300@31
|
779
|
rt300@31
|
780 nextStep.type = AnimStep::MATCHING_MOVE;
|
rt300@31
|
781 nextStep.showsResultsAtEnd = true;
|
rt300@35
|
782
|
rt300@31
|
783 steps.push_back(nextStep);
|
rt300@31
|
784
|
rt300@31
|
785 if (SPACER_BARS){
|
rt300@35
|
786 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@31
|
787 steps.push_back(nextStep);
|
rt300@31
|
788
|
rt300@31
|
789 }
|
rt300@31
|
790 n++;
|
rt300@31
|
791
|
rt300@31
|
792 }
|
rt300@31
|
793
|
rt300@35
|
794 nextStep.type = AnimStep::MATCHING_LAST;
|
rt300@35
|
795 nextStep.presetIndex = -1;
|
rt300@39
|
796 nextStep.whichInSequence = 0;
|
rt300@39
|
797 nextStep.showsGuides = false; // so you know when to go to neutral
|
rt300@31
|
798 nextStep.showsResultsAtEnd = false;
|
rt300@31
|
799 steps.push_back(nextStep);
|
rt300@31
|
800
|
rt300@21
|
801 steps.back().isLastOfSeq = true;
|
rt300@21
|
802 curTempo += tempoInc;
|
rt300@21
|
803 seqNo++;
|
rt300@21
|
804 cout << endl;
|
rt300@21
|
805
|
rt300@21
|
806 }
|
rt300@27
|
807 // ANIM nextStep.setAsBlankCounter();
|
rt300@27
|
808 nextStep.type = AnimStep::MATCHING_NEUTRAL_COUNT;
|
rt300@22
|
809 steps.push_back(nextStep);
|
rt300@21
|
810
|
rt300@21
|
811 }
|
rt300@27
|
812 //-----------------------------------------------------------------------
|
rt300@31
|
813 void SequenceController::saveResultForCurrentStep(TrainingTestResult result){
|
rt300@31
|
814 (*currentStep).saveResult(result);
|
rt300@31
|
815
|
rt300@31
|
816 }
|
rt300@31
|
817 //-----------------------------------------------------------------------
|
rt300@31
|
818 TrainingTestResult SequenceController::getResultForPreviousStep(){
|
rt300@31
|
819 if (currentStep == steps.begin()){
|
rt300@43
|
820
|
rt300@31
|
821 cout << "ERROR - " << endl;
|
rt300@43
|
822
|
rt300@31
|
823 }
|
rt300@31
|
824 return (*currentStep--).result;
|
rt300@31
|
825
|
rt300@43
|
826
|
rt300@31
|
827 }
|
rt300@31
|
828 //-----------------------------------------------------------------------
|
rt300@21
|
829
|
rt300@21
|
830
|
rt300@21
|
831 int SequenceController::getRandomButNot(int max, vector<int> notThese){
|
rt300@21
|
832
|
rt300@21
|
833 bool there = true;
|
rt300@21
|
834 int randomInt = rand() % max;
|
rt300@21
|
835
|
rt300@21
|
836 if (notThese.size()){
|
rt300@21
|
837 while(there){
|
rt300@21
|
838 randomInt = rand() % max;
|
rt300@21
|
839 vector<int>::iterator result = std::find(notThese.begin(), notThese.end(), randomInt);
|
rt300@21
|
840 there = (result != notThese.end());
|
rt300@21
|
841 }
|
rt300@21
|
842 }
|
rt300@21
|
843 return randomInt;
|
rt300@21
|
844
|
rt300@21
|
845 }; |