annotate SequenceController.h @ 41:ba426cc4e6e1

better sequence gen , same for easy (1) and hard (many ) seq fixed judder on sliders
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 05 Dec 2014 18:36:05 +0000
parents 96ff7b41923a
children 2bd658b44c2d
rev   line source
rt300@8 1 //
rt300@14 2 // SequenceGenerator.h
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@14 9 #ifndef __riftathon__SequenceGenerator__
rt300@14 10 #define __riftathon__SequenceGenerator__
rt300@8 11
rt300@8 12 #include <iostream>
rt300@14 13 #include "ofMain.h"
rt300@31 14 #include "presetManager.h"
rt300@31 15 #include "TrainingScoreManager.h"
rt300@36 16
rt300@41 17 #define MIN_TARGETS_IN_SEQUENCE 3
rt300@39 18 #define NUM_REPETITIONS_AT_LEVEL 2
rt300@39 19 #define MAX_TARGETS_IN_SEQUENCE 3
rt300@36 20 #define MIN_TEMPO 70
rt300@38 21 #define MAX_TEMPO 500
rt300@36 22 #define TEMPO_RANDOM_AMOUNT
rt300@36 23 #define MAX_TIME 2800
rt300@36 24 #define MIN_TIME 200
rt300@38 25 #define NUM_TEMPO_STEPS 20
rt300@41 26 #define END_NEUTRAL_MATCH 0
rt300@36 27
rt300@14 28 #define NUM_PRESETS 8
rt300@31 29 #define SPACER_BARS false
rt300@31 30 #define NO_GUIDES_LEVEL false
rt300@36 31
rt300@27 32 class AnimStep{
rt300@10 33
rt300@27 34
rt300@27 35 public:
rt300@27 36
rt300@27 37 AnimStep();
rt300@27 38 typedef enum {PREVIEW_NEUTRAL_COUNT,
rt300@27 39 MATCHING_NEUTRAL_COUNT,
rt300@27 40 PREVIEW_MOVE,
rt300@35 41 PREVIEW_LAST,
rt300@31 42 GUIDED_MOVE,
rt300@31 43 GUIDED_HIT,
rt300@27 44 MATCHING_MOVE,
rt300@35 45 MATCHING_LAST}
rt300@27 46 stepType;
rt300@27 47
rt300@27 48 stepType type;
rt300@36 49 int getTimeAllowed(){
rt300@36 50 return timeAllowedMs;
rt300@36 51 }
rt300@27 52 float getTimeBetweenTicks(){
rt300@36 53 //return 1000* (60.0/tempo);
rt300@36 54 return timeAllowedMs/4.0;
rt300@36 55 }
rt300@36 56
rt300@36 57 void setTempoFromTime(){
rt300@36 58 tempo = 60.0 / (4* timeAllowedMs*1000.0);
rt300@36 59 }
rt300@36 60 void setTimeFromTempo(){
rt300@36 61 timeAllowedMs = 4*1000* (60.0/tempo);
rt300@27 62 }
rt300@27 63 int presetIndex;
rt300@31 64 Preset * currentTargetPreset;
rt300@31 65 Preset * nextTargetPreset;
rt300@27 66 int whichInSequence;
rt300@27 67 bool isLastOfAll;
rt300@27 68
rt300@27 69 int tempo;
rt300@36 70 int tempoLevel;
rt300@36 71 int timeAllowedMs;
rt300@27 72 int seqNumber;
rt300@27 73 int runNumber;
rt300@35 74 int difficulty;
rt300@27 75 bool isLastOfSeq;
rt300@27 76 bool isLastOfRun;
rt300@27 77
rt300@27 78 bool showsGuides; // depends on 'level'
rt300@31 79 bool showsIcons;
rt300@31 80 bool showsResultsAtEnd;
rt300@27 81
rt300@27 82 vector<int> thisSequence; // so that we can show the whole sequence at the top?
rt300@31 83
rt300@31 84 TrainingTestResult result; // only applies to steps that were scored.
rt300@31 85
rt300@31 86
rt300@31 87 void saveResult(TrainingTestResult result);
rt300@27 88 };
rt300@22 89
rt300@31 90 // NOT USED
rt300@14 91 class Step{
rt300@13 92 public:
rt300@22 93 typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes;
rt300@21 94
rt300@21 95 Step();
rt300@21 96
rt300@14 97 // gui display
rt300@14 98 bool showsTargetIcon;
rt300@14 99 bool showsControlSettings;
rt300@14 100 bool showsControlGuides;
rt300@14 101 bool showsMatchResults;
rt300@14 102 // gui input
rt300@14 103 bool allowsCandidateControl;
rt300@14 104 // sound
rt300@14 105 bool playsTarget;
rt300@14 106 bool playsCandidate;
rt300@14 107 // control flow
rt300@14 108 stepTypes type;
rt300@14 109 bool isPreview;
rt300@14 110
rt300@14 111 int seqNumber;
rt300@14 112 int runNumber;
rt300@14 113 bool isLastOfSeq;
rt300@14 114 bool isLastOfRun;
rt300@22 115 bool showsCountDown;
rt300@22 116 bool hidesSliders;
rt300@14 117 int tempo;
rt300@14 118 // preset info
rt300@14 119 int presetIndex;
rt300@14 120 int numInSequence;
rt300@14 121 bool isLastOfAll;
rt300@21 122
rt300@22 123 void setAsBlankCounter();
rt300@22 124 void setAsPreviewPreparer();
rt300@21 125 void setAsPreviewPlayer();
rt300@21 126 void setAsMatchingPreparer();
rt300@22 127 void setAsMatchingInteraction();
rt300@22 128 void setAsMatchingFeedback();
rt300@31 129
rt300@13 130 };
rt300@13 131
rt300@10 132 class SequenceController{
rt300@10 133 public:
rt300@21 134 SequenceController();
rt300@32 135 void init(bool asoundOnlyMode);
rt300@27 136 AnimStep getNextStep();
rt300@21 137 void setToStart();
rt300@21 138 void stepForward();
rt300@21 139 float getStartTickTime();
rt300@31 140 void saveResultForCurrentStep(TrainingTestResult result);
rt300@31 141 TrainingTestResult getResultForPreviousStep();
rt300@32 142 int getTotNumRuns(){return totNumRuns;};
rt300@14 143 private:
rt300@21 144 void generateSteps();
rt300@21 145 void generateCountIn(int countInLength);
rt300@41 146 void generateRun(int run, int numInSequence);
rt300@41 147 void generateARun(int run, int numInSequence); // use this
rt300@34 148 void generateAnEasyRun(int run, int numInSequence = 1);
rt300@32 149 void generateASoundOnlyRun(int run, int numInSequence);
rt300@27 150 vector<int> randomSequence(int numInSequence);
rt300@32 151 vector<int> nonRandomSequence(int numInSequence);
rt300@21 152 int getRandomButNot(int max, vector<int> notThese);
rt300@41 153 void makeGuidedSequence(vector<int> stepPresetIndices, int run, AnimStep& nextStep);
rt300@41 154 void makeMatchingSequence(vector<int> stepPresetIndices, int run, AnimStep& nextStep);
rt300@41 155 void makePreview(vector<int> stepPresetIndices, int run, AnimStep& nextStep);
rt300@21 156 protected:
rt300@27 157 vector<AnimStep> steps;
rt300@27 158 vector<AnimStep>::iterator currentStep;
rt300@13 159 float tempoInc;
rt300@36 160 int timeInc;
rt300@32 161 bool soundOnlyMode;
rt300@32 162 int totNumRuns;
rt300@8 163 };
rt300@8 164
rt300@14 165 #endif /* defined(__riftathon__SequenceGenerator__) */